List all tables with specified field

By

Posted on Sep 18, 2008 by in SQL Server

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

Tags: Tags: t-sql
This entry was posted by and is filed under SQL Server. Tags: t-sql
Tags: t-sql

No feedback yet


Form is loading...