Friday 31 May 2013

How to get all table name dependent on any column in SQl Server

Query for this is

SELECT o.Name as Table_Name , c.Name as Field_Name, t.Name as Data_Type
, t.length as Length_Size
FROM syscolumns c
     INNER JOIN sysobjects o ON o.id = c.id
     LEFT JOIN  systypes t on t.xtype = c.xtype 
WHERE o.type = 'U'  and c.name like '%country%'
ORDER BY o.Name, c.Name

here red color name is your required column name .