当前位置: 数据库>sqlserver
sql server中查找特定类别的列的写法
来源: 互联网 发布时间:2014-08-29
本文导语: 要对特定类别的列进行一些操作,写了以下的一段代码,比较方便检查数据库内同一类别的所有列,示例用来查所有nvarchar的列。 代码如下: select a.name, o.name AS TableName, o.type, a.id, o.object_id, o.schema_id FROM sys.syscolumns AS a INNE...
要对特定类别的列进行一些操作,写了以下的一段代码,比较方便检查数据库内同一类别的所有列,示例用来查所有nvarchar的列。
代码如下:
select a.name, o.name AS TableName, o.type, a.id, o.object_id, o.schema_id
FROM sys.syscolumns AS a INNER JOIN sys.systypes AS b ON a.xtype = b.xtype
AND b.name = 'nvarchar'
INNER JOIN
sys.objects AS o ON a.id = o.object_id
WHERE (o.type = 'u')
AND (o.schema_id = 1)
FROM sys.syscolumns AS a INNER JOIN sys.systypes AS b ON a.xtype = b.xtype
AND b.name = 'nvarchar'
INNER JOIN
sys.objects AS o ON a.id = o.object_id
WHERE (o.type = 'u')
AND (o.schema_id = 1)