List all tables with specified field


DECLARE @COL_NAME NVARCHAR(50)
SET @COL_NAME = '%SOMESTRING%'

SELECT     DB_NAME(DB_ID()) AS DatabaseName,
           B.name AS TableName, 
           A.name AS ColumnName
FROM       sys.syscolumns AS A INNER JOIN
               sys.sysobjects AS B ON A.id = B.id
WHERE     (A.name LIKE @COL_NAME) AND (B.type LIKE 'U%')

CU
tosc

No feedback yet
Leave a comment

Your email address will not be revealed on this site.
PoorExcellent
(Line breaks become <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)
Trackback address for this post

http://www.insidesql.org/blogs/htsrv/trackback.php?tb_id=281