IT/MSSQL

임의의 컬럼( column ) 명이 있는 전체 테이블 ( table ) 찾기.

당양부부34 2013. 5. 28. 14:53

select
a.name as table_name,
b.name as column_name,
c.name as data_type,
c.length as data_length
from sys.tables a
inner join sys.syscolumns b on a.object_id=b.id
inner join sys.systypes c on c.xtype=b.xtype
where a.name in
 (
 select name from sysobjects
 where xtype = 'U'
 )
and b.name in ('userid', 'user_id')
order by table_name