首页 > 代码库 > sqlserver 查询表结构,字段,类型,长度,描述信息通通有

sqlserver 查询表结构,字段,类型,长度,描述信息通通有

select sys.columns.name as 字段名, sys.types.name as 字段类型, sys.columns.max_length as 长度, sys.columns.is_nullable as 是否可空,(selectcount(*) from sys.identity_columns where sys.identity_columns.object_id= sys.columns.object_idand sys.columns.column_id = sys.identity_columns.column_id) as 是否自增长 ,(select value from sys.extended_properties where sys.extended_properties.major_id = sys.columns.object_idand sys.extended_properties.minor_id = sys.columns.column_id) as 描述from sys.columns, sys.tables, sys.types where sys.columns.object_id= sys.tables.object_idand sys.columns.system_type_id=sys.types.system_type_id and sys.tables.name=TableName orderby sys.columns.column_id
View Code