1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| USE yourDataBaseName GO
SELECT 'IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N''' + DC.Name + ''') and Type = ''D'') ALTER TABLE [' + OBJECT_SCHEMA_NAME(SO.ID) + '].[' + SO.Name + '] DROP CONSTRAINT [' + DC.Name + ']' FROM SysObjects SO INNER JOIN SysColumns SC ON SO.ID = SC.ID INNER JOIN sys.default_constraints DC ON SO.ID = DC.Parent_object_id AND SC.colid = DC.Parent_column_id WHERE SO.XTYPE = 'U' AND SC.Name = 'msrepl_tran_version' UNION SELECT 'IF EXISTS (SELECT * FROM dbo.syscolumns where id = OBJECT_ID(N''' + SO.Name + ''') and Name = ''msrepl_tran_version'') ALTER TABLE [' + OBJECT_SCHEMA_NAME(SO.ID) + '].[' + SO.Name + '] DROP COLUMN [msrepl_tran_version] ' FROM SysObjects SO INNER JOIN SysColumns SC ON SO.ID = SC.ID INNER JOIN sys.default_constraints DC ON SO.ID = DC.Parent_object_id AND SC.colid = DC.Parent_column_id WHERE SO.XTYPE = 'U' AND SC.Name = 'msrepl_tran_version' ORDER BY 1
|