DECLARE @L VARCHAR(100) = '%Mars%'
DECLARE @TB VARCHAR(100), @CL VARCHAR(100), @Q NVARCHAR(250)
DECLARE @R TABLE ( TableField VARCHAR(100), FieldValue VARCHAR(250) )
DECLARE AllTable CURSOR FOR
SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DATA_TYPE LIKE '%char'
OPEN AllTable
FETCH NEXT FROM AllTable INTO @TB, @CL
WHILE @@FETCH_STATUS = 0 BEGIN
SET @Q = 'SELECT ''' + @TB + '.' + @CL + ''', ' + @CL
+ ' FROM ' + @TB + ' WHERE ' + @CL + ' LIKE ''' + @L + ''''
INSERT @R EXECUTE sp_executesql @Q
FETCH NEXT FROM AllTable INTO @TB, @CL
END
CLOSE AllTable
DEALLOCATE AllTable
SELECT * FROM @R