File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 3333*
3434* Fix bug when user defined types exist by adding additional join clause on sys.types for user_type_id
3535*
36+ * Modified 2023-05-31 by Roelof de Villiers
37+ *
38+ * Include original constraint name when putting back DEFAULT constraints.
39+ *
3640*********************************************************************************/
3741
3842SET NOCOUNT ON ;
@@ -693,7 +697,7 @@ BEGIN;
693697 script)
694698 SELECT ' DropDefault' ,
695699 N' ALTER TABLE ' + QUOTENAME(@SchemaName) + N' .' + QUOTENAME(@TableName) + N' DROP CONSTRAINT '
696- + QUOTENAME(dc .name ) + ' '
700+ + QUOTENAME(dc .name )
697701 FROM sys .columns AS c
698702 INNER JOIN sys .default_constraints dc
699703 ON dc .object_id = c .default_object_id
@@ -709,7 +713,8 @@ BEGIN;
709713 INSERT INTO # tempscriptstore (ScriptType,
710714 script)
711715 SELECT ' CreateDefault' ,
712- N' ALTER TABLE ' + QUOTENAME(@SchemaName) + N' .' + QUOTENAME(@TableName) + N' ADD DEFAULT '
716+ N' ALTER TABLE ' + QUOTENAME(@SchemaName) + N' .' + QUOTENAME(@TableName) + N' ADD CONSTRAINT '
717+ + QUOTENAME(dc .name ) + ' DEFAULT '
713718 + dc .definition + ' FOR ' + QUOTENAME(c .name )
714719 FROM sys .columns AS c
715720 INNER JOIN sys .default_constraints dc on dc .object_id = c .default_object_id
You can’t perform that action at this time.
0 commit comments