January 2, 2014 at 3:27 am
I am trying to script tables using Generate Scripts Wizard. but the script which is created does not have default constraints written to it even though "Script Defaults" is set to True. Any idea why default constraints are not being written to the file.
Any help on this would be grateful. Thanks.
January 2, 2014 at 5:05 am
Right click the table and select "Script table as" > "Create to" > "New query editor window".
Do you see the default constraint script there?
Please post results of the following query
SELECTdc.nameAS ConstraintName
, dc.definitionAS ConstraintDefinition
, dc.type_descAS ConstraintType
, c.nameAS ColumnName
FROM sys.default_constraints dc INNER JOIN sys.columns c
ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
WHERE OBJECT_NAME(c.object_id) = 'yourtablename'
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
January 2, 2014 at 6:01 am
there are a lot of options for scripting that can be enabled/disabled;
take a look in your Tools>>Options (in 2012 SSMS, it's Tools>>Options>>SQL Server Object Explorer>>Scripting
and check your setting for "Script defaults"
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply