SQL Server - To retrieve table names from database with condition on column

Asked By Ranjeet Dhumal on 12-Jan-12 02:17 AM
Hi..
I want to retrieve table names from database with condition on a perticular column.
examle:
Column Name='Description'

SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE LEN(Decription)>=40;

Will it work ? or is there any other solution for it.

Thank You.
Venkat K replied to Ranjeet Dhumal on 12-Jan-12 03:13 AM

YOu wont get the columns names information in INFORMATION.TABLES rather you need to query the INFORMATION_SCHEMA.Columns and get the distinct tablenames from the query as shown below.

SELECT

DISTINCT(TABLE_NAME)


FROM INFORMATION_SCHEMA.Columns


WHERE <<condition for length of column>>

Thanks

Sandeep Mittal replied to Ranjeet Dhumal on 12-Jan-12 04:17 AM
Check if you are looking for this

SELECT  distinct object_name(id)
FROM    syscolumns
where   lower(name) = 'description'
and length > 40