SQL查询数据库中所有指定类型的字段名称和所在的表名

--查询数据库中所有指定类型的字段名称和所在的表名
--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 TableName
FROM sys.columns cols
LEFT JOIN sys.objects AS obj ON cols.object_id = obj.object_id
WHERE TYPE_NAME(system_type_id) = 'nvarchar'
AND max_length = -1
上一篇:PHP Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in /usr/local/php/CreateDB.php on line 5


下一篇:zoj 3601