Created
January 20, 2012 20:48
-
-
Save bemasher/1649477 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT 'DELETE FROM ' + a.TABLE_NAME + ' WHERE PrimaryKeyColumn IN (SELECT PrimaryKeyColumn FROM @WhatToDelete)' | |
FROM INFORMATION_SCHEMA.COLUMNS a | |
JOIN INFORMATION_SCHEMA.TABLES b ON a.TABLE_NAME = b.TABLE_NAME | |
WHERE COLUMN_NAME LIKE 'PrimaryKeyColumn' AND b.TABLE_TYPE = 'BASE TABLE' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment