I have one specific string, such as \"123abcd\" for example but I don\'t know the name of the table or even the name of the column inside the table on my SQL Server Database
I usually use information_Schema.columns
and information_schema.tables
, although like @yuck said, sys.tables
and sys.columns
are shorter to type.
In a loop, concatenate these
@sql = @sql + 'select' + column_name +
' from ' + table_name +
' where ' + column_name ' like ''%''+value+''%' UNION
Then execute the resulting sql.
Common Resource Grep (crgrep) will search for string matches in tables/columns by name or content and supports a number of DBs, including SQLServer, Oracle and others. Full wild-carding and other useful options.
It's opensource (I'm the author).
http://sourceforge.net/projects/crgrep/
I think you have to options:
Build a dynamic SQL using sys.tables
and sys.columns
to perform the search (example here).
Use any program that have this function. An example of this is SQL Workbench (free).