1 DECLARE @base nvarchar(max),
5 SET @base = 'ALTER TABLE /*_*/logging DROP CONSTRAINT ';--
8 FROM sys.foreign_keys fk
9 JOIN sys.foreign_key_columns fkc
10 ON fkc.constraint_object_id = fk.object_id
12 ON c.column_id = fkc.parent_column_id
13 AND c.object_id = fkc.parent_object_id
15 fk.parent_object_id = OBJECT_ID('/*_*/logging')
16 AND fk.referenced_object_id = OBJECT_ID('/*_*/mwuser')
17 AND c.name = 'log_user';--
19 SET @SQL = @base + @id;--
21 EXEC sp_executesql @SQL;--
24 FROM sys.foreign_keys fk
25 JOIN sys.foreign_key_columns fkc
26 ON fkc.constraint_object_id = fk.object_id
28 ON c.column_id = fkc.parent_column_id
29 AND c.object_id = fkc.parent_object_id
31 fk.parent_object_id = OBJECT_ID('/*_*/logging')
32 AND fk.referenced_object_id = OBJECT_ID('/*_*/page')
33 AND c.name = 'log_page';--
35 SET @SQL = @base + @id;--
37 EXEC sp_executesql @SQL;