SQL Server 查询数据库中所有指定类型的字段名称和所在的表名 Posted on 2016-11-30 | Post modified: 2016-11-30 | Visitors: SQL Server 查询数据库中所有指定类型的字段名称和所在的表名 123456789101112--查询数据库中所有指定类型的字段名称和所在的表名--eg: 下面查的是当前数据库中 所有字段类型为 nvarchar(max) 的字段名和表名SELECT cols.object_id , cols.column_id , cols.name AS ColumnName , TYPE_NAME(cols.system_type_id) AS ColumnType , cols.max_length , obj.name AS TableNameFROM sys.columns cols LEFT JOIN sys.objects AS obj ON cols.object_id = obj.object_idWHERE TYPE_NAME(system_type_id) = 'nvarchar' AND max_length = -1