I am running the following code to extract all relevant rows from all tables that have a particular column. The outer IF is supposed to check if the column exists o
USE WS_Live
EXECUTE sp_MSforeachtable
'
USE WS_Live
IF EXISTS( SELECT *
FROM sys.columns
WHERE columns.Object_ID = Object_ID(''?'')
AND Name = ''GCRecord''
)
BEGIN
EXEC(''SELECT * FROM ? WHERE GCRecord IS NOT NULL'')
END
'