Query to find a specific column in all the tables of database

Posted: January 19, 2009 in Sqlserver

  

SELECT dbo.sysobjects.name AS TableName, dbo.syscolumns.name AS ColumnName,
dbo.systypes.name AS Datatype, dbo.sysobjects.xtype
FROM
dbo. sysobjects

 

INNER JOIN dbo.syscolumns ON dbo.sysobjects.id = dbo.syscolumns. id  

INNER JOIN dbo.systypes ON dbo.syscolumns.xtype =dbo.systypes. xtype 

 WHERE  (dbo.sysobjects.xtype = ‘U’AND  (dbo.syscolumns.name LIKE‘%EmplID%’)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s