Tuesday, 15 May 2012

SQL To find tables which contain a particular column


In some case we might need to find the table name that uses a specific columns like ID’s column that are used across several tables in database and we won’t be able to navigate to all the tables to identify the column and its table so the below query solve the issue.


SELECT s.name AS [Table Name] FROM SYSOBJECTS s
INNER JOIN SYSCOLUMNS sc
ON s.id = sc.id
WHERE sc.name LIKE '<column name>'

No comments:

Post a Comment