SQL Server: Find tables containing column name

To find all the user tables that contain a particular column name run the following command on the relevant database:

SELECT name FROM sysobjects WHERE xtype='U' and id IN( SELECT id FROM syscolumns
WHERE name like '%COLUMN NAME%' )
Advertisement

About kievia

Christian, Geek, Youth Worker, Bookworm

Posted on July 20, 2010, in IT and tagged . Bookmark the permalink. Leave a Comment.

Leave a Reply

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

Gravatar
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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.