开发者

list of table which has the column in sql server 2005

In my 开发者_C百科database, I have many tables which has the column StudentId, how can I get the list of the table which has this column in sql server 2005?


I would also like to add that Red-Gate Software has an absolutely free tool called SQL Search that is just absolutely wonderful to use and does this job with ease.

list of table which has the column in sql server 2005


SELECT * FROM 
INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c
ON t.TABLE_NAME = c.TABLE_NAME
WHERE c.COLUMN_NAME='StudentId'


Do a SELECT * FROM sys.columns WHERE name = 'colname' and then you can join that back to sys.tables on object_id. I dont have Sql Server on my pc now, but this should be very close.


SELECT t.name 
FROM sys.table t INNER JOIN sys.column c
    ON c.objectid = t.objectid AND c.name LIKE 'studentid'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜