While I think this request is somewhat odd... silly even, it was kinda fun to mock up a sample:WARNING: this could be dangerous to run if you are working with a large Db. (large in table counts, column counts, or row counts)P.S. - this only provides the tables and columns that provide matches. More work will need to be done from there if more than 1 result returns.Declare @findData varchar(100), @isDate bit, @isNumeric bit, @isInt bit, @isBit bit, @isDecimal bitSet @findData = 'Search for this string!'--Set @findData = '4561347' -- or this number--Set @findData = '4/23/1980' -- or this DateSet @isDate = isdate(@findData)Set @isNumeric = isNumeric(@findData)if (@isNumeric=1)Begin Set @isInt = case when convert(decimal(18,9),@findData) - convert(int,convert(decimal(18,9),@findData)) = 0 then 1 else 0 end Set @IsDecimal = 1EndElseBegin Set @isInt = 0 Set @IsDecimal = 0EndSet @isBit = case when @findData in ('0','1','true','false') then 1 else 0 endDeclare @t table ( sqlStr varchar(500))Insert Into @tSelect 'Select tableName=''' + A.Name + ''', ColumnName=''' + B.Name + ''', Value=convert(varchar,'+ B.Name + '), Cnt=Count(*) From ' + A.Name + ' Where ' + B.Name + ' = convert(' + C.Name + ',''' + @findData + ''') Group By convert(varchar,'+ B.Name + ')' --,A.Name, C.Name, B.*From sysobjects AInner Join syscolumns BOn A.id = B.idInner Join systypes COn B.xType = C.xTypeWhere A.type = 'U'and ( (C.Name in ('int') and @isInt = 1) or (C.Name in ('decimal','float','money') and @isDecimal = 1) or (C.Name in ('datetime','smalldatetime') and @isDate = 1) or (C.Name in ('bit') and @isBit = 1) or C.Name in ('char','varchar','nvarchar','nchar') --or --C.Name not in ('int','datetime','bit','char','varchar','money','nchar','nvarchar','image','text','sysname','binary','varbinary','xml','smalldatetime','decimal'))--Select * From @tDeclare @results table ( TableName varchar(100), ColumnName varchar(100), Value varchar(100), Cnt int)Declare @sqlStr varchar(500)While exists(Select * From @t)Begin Set @sqlStr = (Select top 1 sqlStr From @t) Delete From @t Where sqlStr = @sqlStr Insert Into @results Exec(@sqlStr)EndSelect * From @resultsCorey
I Has Returned!!