Is it possible via scripts / tools that remove deleted statement based on the table.
That is Table I: Delm (ID) and 30 table whose ID has been deleted in the context of Fk, which need to be removed before me, that there are some tools / scripts I So that 30 delicate statements can be generated on the basis of FK relations.
(Biteedbluti I know to delete cascade relationships, I can not use it in the current DB)
I am using Microsoft SQL Server 2008
to use the SP with the parameters, and deleted trigger Dilite statement to be used as: ( this version supports only one column FKs)
SELECT 'DELETE' + detail.name + 'WHERE' + dcolumn.name + '= @' + mcolumn.name AS a Samtie, 'DELETE' + detail.name + 'FROM' + in detail. Name + 'Inner has joined' + Extension. Name + '.' + Dcolumn.name + '= Deleted.' + Mcolumn.name AS tr.gr sys.column AS mcolumn INNER JOIN at sys.foreign_key_columns mcolumn.object_id = sys.foreign_key_columns.referenced_object_id and mcolumn.column_id = sys.foreign_key_columns.referenced_column_id INNER joins sys.tables master mcolumn.object_id = master .object_id INNER Join sys.column as dcolumn oN sys.foreign_key_columns.parent_object_id = dcolumn.object_id and sys.foreign_key_columns.parent_column_id = dcolumn.column_id INNER Join sys.tables as details dcolumn.object_id = detail.object_id WHERE ( Master.name = N'MyTableName ')
Comments
Post a Comment