Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Generate Table Scripts Expand / Collapse
Posted Thursday, January 2, 2014 3:27 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, October 2, 2015 6:45 AM
Points: 283, Visits: 482
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.
Post #1527025
Posted Thursday, January 2, 2014 5:05 AM



Group: General Forum Members
Last Login: Yesterday @ 2:47 PM
Points: 7,778, Visits: 15,814
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

SELECT			AS ConstraintName
, dc.definition AS ConstraintDefinition
, dc.type_desc AS ConstraintType
, AS 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"
Post #1527043
Posted Thursday, January 2, 2014 6:01 AM



Group: General Forum Members
Last Login: Yesterday @ 7:36 PM
Points: 13,884, Visits: 35,806
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"


help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  Post Attachments 
Script_defaults.png (20 views, 73.28 KB)
Post #1527072
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse