- Written by
belle
- Posted May 16, 2009 at 7:27 pm
There are several ways to look for a column in your SQL Server database.
Alternative 1: INFORMATION_SCHEMA.COLUMNS (T-SQL)
DECLARE @colName NVARCHAR(30)
SET @colName = 'name'
SELECT
TABLE_CATALOG AS 'Database',
TABLE_SCHEMA AS 'Schema',
TABLE_NAME AS 'Table',
COLUMN_NAME AS 'Column'
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
COLUMN_NAME LIKE '%' + @colName + '%'
Alternative 2: sys.columns (T-SQL)
SELECT
sys.tables.name AS 'Table',
sys.columns.name AS 'Column'
FROM
sys.columns
INNER JOIN sys.tables
ON sys.tables.object_id = sys.columns.object_id
WHERE
sys.columns.name LIKE '%' + @colName + '%'
Alternative 3: Object Search (SSMS)
In SQL Server 2000, there was an “Object Search” tool in Query Analyzer to search for objects.
To get to this tool in SQL Server 2000, either
- Go to Tools > Object Search, or
- Press F4
Unfortunately this was removed in SQL Server 2005.
But back again in SQL Server 2008:
- Go to View > Object Explorer Details
- Type object name in the Search bar
- Press Enter to Search
Yay!
VN:F [1.9.7_1111]
Rating: 10.0/10 (4 votes cast)
VN:F [1.9.7_1111]