News

Copyright © 2008-2018 Paula DiTallo

Tag Cloud



How do I find all instances of a column name in my SQL Server database?

 

The objects that help you find this info in SQL Server are in sys.tables and sys.columns

SELECT tbl.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name
,
col.name AS
column_name
FROM sys.tables AS
tbl
INNER JOIN sys.columns col ON tbl.OBJECT_ID = col.
OBJECT_ID
WHERE col.name LIKE
'%YourColumnNameHere%'
ORDER BY schema_name, table_name;

This will bring back every table that has a reference to '%YourColumnNameHere%'

 

Sunday, October 10, 2010 10:27 PM

Feedback

# re: How do I find all instances of a column name in my SQL Server database?

Nice Article !

Really this will help to people of SQL Server Community.
I have also prepared small note on this, How to find all columns information of SQL Server Database.

http://www.dbrnd.com/2015/10/sql-server-script-to-find-all-columns-information-of-a-database/ 2/19/2016 4:08 AM | Anvesh

Post A Comment
Title:
Name:
Email:
Comment:
Verification: