BRONZE PARTNER:
BRONZE PARTNER:
Industry News:

| |
 |
 |
 |
| SQL Query To Find Specified Table Column Names |
 |
|
|
By: Don Hite
Posted On: 11/28/2007
This article was Previously posted on Don Hite's Blog
This script will allow you look for any specified column name from all of the user tables from within the current database object. This can be of particular interest to those wanting for example to find which SQL table holds the LastHWScan column.
SQL Query:
Set NoCount On Declare @ColVar VarChar(25) Set @ColVar = '%last%' -- String To Find
Select SysObjects.Name 'Table Names:', SysColumns.Name 'Column Names:'
From SysObjects, SysColumns, SysTypes
Where SysObjects.ID = SysColumns.ID And SysColumns.xType = SysTypes.xType And SysColumns.Name like @ColVar
Order by SysObjects.Name Asc Set NoCount Off
Usage Examples:
Pattern Match Set @ColVar = '%Last%' Set @ColVar = '%last%time%'
Exact Match Set @ColumnNames = 'Last'
|
 |
 |
 |
|
|