SQL Server - Find all Tables in Database that contains a specific column

Thursday, 25 June 2009 10:59 by myro

If you need to query your sql server's database to find out where a specific column is present into a table's schema, you can lauch this query against your database.

USE YOUR_DATA_BASE_NAME
GO
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 '%YOUR_Column_NAME%'
ORDER BY schema_name, table_name;

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Sql
Actions:   Bookmark and Share | Permalink | Comments (2) | Comment RSSRSS comment feed
If you consider this post usefull for your purposes, please consider visiting my sponsors to help me out with the myrocode.com maintenance. Thank you.

Comments