Archives for the 'MS SQL' Category

Search for Column Name in All Tables

In MS SQL Server 2000 and above there is an undocumented stored procedure that enables you to search through all tables for a particular column name. Example usage:
PLAIN TEXT
SQL:

sp_MSforeachdb

'print ''?'';

use [?];

select table_name

from information_schema.columns

where column_name like ''TheColumnNameToFind'''

Note: select the "Results in Text" or "Results to Text" option before executing the above.
Thanks to my friend [...]

22 April 2008 | MS SQL | No Comments