SELECT [表名]=CASE WHEN T.column_id = 1 THEN OBJECT_NAME(T.object_id) ELSE ‘‘ END , [字段编号]=T.column_id, [字段名]=T.name, [主键]=case when exists(SELECT 1 FROM sys.key_constraints where type=‘PK‘ and object_id=T.OBJECT_ID) THEN ‘●‘ ELSE ‘‘ END, [标识列]=CASE T.is_identity WHEN 1 THEN ‘●‘ ELSE ‘‘ END, [计算列]=CASE T.is_computed WHEN 1 THEN ‘●‘ ELSE ‘‘ END, [字段类型]=(SELECT name FROM sys.types WHERE user_type_id = T.user_type_id), [字段长度]= T.PRECISION, [小数位] = T.Scale, [允许空] = CASE T.is_nullable WHEN 1 THEN ‘●‘ ELSE ‘‘ END, [默认值]= ISNULL((SELECT definition from sys.default_constraints where object_id = T.default_object_id),‘‘), [字段说明]=(SELECT VALUE FROM sys.extended_properties WHERE major_id = T.OBJECT_ID AND minor_id =T.column_id) FROM sys.COLUMNS T INNER JOIN sys.objects O ON T.object_id = O.object_id AND O.type = ‘U‘ WHERE RIGHT(OBJECT_NAME(T.object_id),3) <> ‘Log‘ AND OBJECT_NAME(T.object_id) <>‘AuditDDLEvents‘ AND OBJECT_NAME(T.object_id) <>‘dtproperties‘ ORDER BY OBJECT_NAME(T.object_id),T.column_id
时间: 2024-10-10 17:32:52