SELECT a.nonono 归纳 ,
a.tablename 表名 ,
a.name 列名 ,
a.Typename 类型 ,
a.max_length 最大长度 ,
a.precision 精度 ,
a.is_nullable 是否为空 ,
ISNULL(sys.extended_properties.value, '') 注释
FROM ( SELECT ' ' nonono ,
sys.tables.name tablename ,
sys.columns.name ,
sys.types.name Typename ,
CONVERT(CHAR, sys.columns.max_length) max_length ,
CONVERT(CHAR, sys.columns.precision) precision ,
CONVERT(CHAR, sys.columns.is_nullable) is_nullable ,
sys.columns.column_id ,
sys.tables.object_id
FROM sys.tables ,
sys.columns ,
sys.types
WHERE sys.tables.object_id = sys.columns.object_id
AND sys.types.system_type_id = sys.columns.system_type_id
AND sys.types.user_type_id = sys.columns.user_type_id
UNION
SELECT sys.tables.name nonono ,
sys.tables.name tablename ,
'' name ,
'' Typename ,
'' max_length ,
'' precision ,
'' is_nullable ,
0 column_id ,
sys.tables.object_id
FROM sys.tables
) a
LEFT JOIN sys.extended_properties ON a.object_id = sys.extended_properties.major_id
AND a.column_id = sys.extended_properties.minor_id
GROUP BY a.nonono ,
a.tablename ,
a.name ,
a.Typename ,
a.precision ,
a.is_nullable ,
a.max_length ,
a.column_id ,
a.object_id ,
sys.extended_properties.value
ORDER BY a.tablename ,
a.column_id ;
转载于:https://www.cnblogs.com/MoonbasaDesign/archive/2012/04/15/PureSQLToPowerDesigner.html