Some times while working with lots of data we forget "Which table this column belong to?". And in that case we start going through each and every table to find out that particular column. Now instead of doing that you just need to write a query as following:
SELECT t . name AS table_name ,
SCHEMA_NAME ( schema_id ) AS schema_name ,
c . name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t . OBJECT_ID = c . OBJECT_ID
WHERE c . name LIKE '%NAME%'
ORDER BY schema_name , table_name ;
And here instead of '%NAME%', you are supposed to write the exact column column name or a part of it, like '%AGE%' or '%ADDRESS%' etc.....
After running this query you will get a number of tables which contain this particular column And thats how it makes your life simple. Enjoy.:)
SELECT t . name AS table_name ,
SCHEMA_NAME ( schema_id ) AS schema_name ,
c . name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t . OBJECT_ID = c . OBJECT_ID
WHERE c . name LIKE '%NAME%'
ORDER BY schema_name , table_name ;
And here instead of '%NAME%', you are supposed to write the exact column column name or a part of it, like '%AGE%' or '%ADDRESS%' etc.....
After running this query you will get a number of tables which contain this particular column And thats how it makes your life simple. Enjoy.:)
No comments:
Post a Comment