SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Get Tables by column name

By Deepthi Viswanathan Nair,

This script search the tables in the database whcih has the given column name. This query looks for the column Employee_Id field in tables and list out the table names. This uses sysobjects , syscolumns system table to search the column name. sysobjects.xtype = 'u' means to look for only the user tables.

You can also search for multiple columns by adding the condition in the where clasue as follows.

syscolumns.name like '%Employee_Id%' or syscolumns.name like '%Employee_Number%'

Here it search the tables with column Employee_Id and Employee_Number.


Total article views: 1041 | Views in the last 30 days: 1
Related Articles

Searching Column Name in All Tables

Use this script to search for a specific column name in all tables in a current database.


Search for a Column in all databases

This Script can be used for searching a column in SQL server 2005


String Search

Search for a string value within columns of data types CHAR, NCHAR, NTEXT, NVARCHAR, TEXT, VARCHAR, ...


sql query need Help about Absent Employee

Query about absent employee


Employee Retention

A SQL Server DBA seems to be a stable job and many of us stick with the same job for an above averag...