Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 986 | Views in the last 30 days: 2
 
Related Articles
SCRIPT

Searching Column Name in All Tables

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

SCRIPT

Search for a Column in all databases

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

SCRIPT

String Search

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

FORUM

sql query need Help about Absent Employee

Query about absent employee

ARTICLE

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...

Tags
tables    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones