最近在做个project,需要对特定类别的列进行一些操作,为了避免遗漏,所以弄了这个script,比较方便检查数据库内同一类别的所有列,记录一下,备用,例子里面是来查所有nvarchar的列.
1: SELECT a.name, o.name AS TableName, o.type, a.id, o.object_id, o.schema_id
2: FROM sys.syscolumns AS a INNER JOIN sys.systypes AS b ON a.xtype = b.xtype
3: AND b.name = 'nvarchar'
4: INNER JOIN
5: sys.objects AS o ON a.id = o.object_id
6: WHERE (o.type = 'u')
7: AND (o.schema_id = 1)