I\'m new to MsSql and I\'m not sure if this can be done but I figured I\'d ask before I want on my way with the current process..
I need to create a script that loops th
sp_MSForEachTable is an undocumented stored procedure which will run a command for each table in the database:
USE MyDatabase
DECLARE @CorporationId VARCHAR(50)
SET @CorporationId = '52D3AEFE-8EBD-4669-8096-4596FE83BB36'
DECLARE @Sql VARCHAR(MAX)
SET @Sql = '
IF COL_LENGTH(''?'',''CorporationId'') IS NOT NULL
BEGIN
DELETE FROM Web.?
WHERE CorporationId = ''' + @CorporationId + '''
END
'
EXEC sp_MSForEachTable @Sql