Sunday, March 4, 2012

Locate a column in a Database



How to Locate a column in a Database

Do you want to locate a specific column  in your database and know its datatype ?
Type in the following query.

SELECT
tbl.name AS TableName,
SCHEMA_NAME(schema_id) AS SchemaName,
col.name AS ColumnName
FROM sys.tables AS tbl
INNER JOIN sys.columns col ON tbl.OBJECT_ID = col.OBJECT_ID
WHERE col.name LIKE '%keyword%'
ORDER BY SchemaName, ColumnName

No comments: