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 .
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 .
Hi,nice sql query for getting all table name based on column in sql server
ReplyDeleteTheosoft
Hii hariharan
DeleteThanks for appricattion.
you can also use another query
SELECT * FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name like '%city%' )
and type='u'
where city is your column name (Tested in SQL server 2008)