You can use the OBJECTPROPERTY()
function in SQL Server to see whether or not a table has a DEFAULT constraint.
To do this, pass the table’s object ID as the first argument, and TableHasDefaultCnst
as the second argument. The function returns a 1
or a 0
depending on whether or not it has a DEFAULT constraint.
A return value of 1
means that the table has a DEFAULT constraint, and a value of 0
means that it’s not.