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
Author
Message
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: Thursday, January 2, 2014 6:26 AM
Points: 283, Visits: 461
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


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:50 AM
Points: 6,175, Visits: 13,319
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		dc.name			AS ConstraintName
, dc.definition AS ConstraintDefinition
, dc.type_desc AS ConstraintType
, c.name 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


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:31 PM
Points: 12,881, Visits: 31,815
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son


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

Add to briefcase

Permissions Expand / Collapse