Aug 18, 2011

Search Column Name

The following query will search the entire AdventureWorks database for any column that looks like ‘address’.
USE AdventureWorks;
GO

SELECT    OBJECT_NAME(id),
        name
FROM    syscolumns
WHERE    name like '%address%'
ORDER BY 1 ASC;

Here’s what we get for the output:
image
You can also see it returns 32 rows that includes tables and views, greatly narrowing your search.  With a tiny bit of insight you can probably narrow your search to 2 or 3 tables.
It’s a simple little query but one that always saves me a bunch of time. 

No comments:

Post a Comment

Hi,

Thanks for your visit to this blog.
We would be happy with your Queries/Suggestions.