Friday, 31 August 2012

SQL Server Scripts : List all tables name that contain particular column name using SQL Query

There are many situations where you want to get all tables name that contains particular column name using sql query.

Here is query for this.
In this query we want to find column "ProductID" in all tables and get list of that.

SQL Query :
select sysobjects.name, * from syscolumns, sysobjects
where syscolumns.name='ProductID'
and sysobjects.id = syscolumns.id
and (sysobjects.xtype='U' or sysobjects.xtype='S')

Output :



This is the very useful SQL Server Scripts.

Note : Give Us your valuable feedback in comments. Give your suggestions in this article so we can update our articles accordingly that.

No comments:

Post a Comment

Post a Comment