Xpode.com        Click here to Print this article.

Query to Find table name from Database having specific column

Some days ago I need to find a table name where a column exist or not. There were around 100 tables, So i need to find a time saving solution. Around net I found a solution for that which solved my problem in a minute. In a community form I found the solution. Solution is given below.

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 '%City%'
ORDER
BY schema_name, table_name;


http://
http://

Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=310

Click here to go on website