Last post Jan 09, 2017 01:20 PM by jayhawker
Jan 09, 2017 12:49 PM|JAYHAWKER|LINK
I know I can use triggers and cascading deletes to delete records from other table with the same column name and column value, but is there a way without having to create a trigger or cascading delete for each table to just do some sort of sweep of them
For example, it would be nice to something like this.
SET NOCOUNT OFF;
DELETE FROM SampleDatabase.AllTables
WHERE (ContactID = @ContactID)
Jan 09, 2017 01:03 PM|PatriceSc|LINK
No, you would have to use code that generate the needed delete statements (for example by querying the Information_Schema.Columns). It might be a bit risky.
Another option is to use a stored procedure you would create once for all. Would be perhaps my personal preference for now, not knowing the exact need.
Jan 09, 2017 01:20 PM|JAYHAWKER|LINK
I thought it was a little wishfull thinking! Thanks for the quick reply!