var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Need help with a query that retrieves DEFAULT constraints
I am trying to write a query that seaches for all DEFAULT constraints in a database and prints the column with the default value, the value of the default, and the name of the default constraint.
So far I have the two queries that let me get all the information I need.
I am unable to merge them into one query. I cannot seem to find a commun field to both of them.
SELECT Name FROM sysobjects
WHERE xtype = 'D'
SELECT column_default, column_name FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_default IS NOT Null
Many thanks in advance.
s.name as DefaultName,
FROM sysobjects s,
xtype = 'D'
and COLUMN_DEFAULT IS NOT null
and c.TABLE_NAME=(SELECT name FROM sysobjects where id=s.parent_obj)
I love cursor,though I never use it.Cos' I dont want to misuse it.
Thanks for your input mallier, but it does not give me the right result.
It actually outputs the same constraint name for each column, for all constraints in a table.
Found it !!!
It took me hours, literally, and it is completely different from the method I proposed first.
SELECT object_name(scol.cdefault) as "ConstraintName",
object_name(scol.id) as "Table",
scol.name as "Column",
FROM syscomments sc, syscolumns scol
WHERE sc.id = scol.cdefault