This procedure can search all columns in one or all tables for a specified string. Prints out the TableName.ColumnName that the string is found in...
-- Example Calls
-- EXECUTE spFindTextInColumns MyTable, 'tcart' --search a specific table
--
-- EXECUTE spFindTextInColumns default, 'tcart' --search all tables
BUG FIX : (2003/01/20)
Changed
SELECT @columnName = [COLUMN_NAME],
to:
SELECT @columnName = '[' + [COLUMN_NAME] ']',
to avoid: Line 1: Incorrect syntax near '~'
Thanks to Avraham de-Haan for pointing this one out.