SELECT TableName=d.name,--表名称 FieldNo=a.colorder,--字段编号 FieldName=a.name,--字段名称 IsIdentity=case when COLUMNPROPERTY(a.id,a.name,'IsIdentity')=1 then 'true'else 'false' end,--是否自增 PrimaryKey=case when exists ( SELECT 1 FROM sysobjects where xtype='PK' and name in ( SELECT name FROM sysindexes WHERE indid in ( SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid ) ) ) then 'true' else 'false' end,--是否主键 FieldType=b.name,--字段类型 FieldLength=a.length,--字段长度 FieldSize=COLUMNPROPERTY(a.id,'PRECISION'),--字段大小 FieldScale=isnull(COLUMNPROPERTY(a.id,'Scale'),0),--小数位数 FieldAllowNull=case when a.isnullable=1 then 'true' else 'false' end,--是否为空 DefaultValue=isnull(e.text,''),--默认值 FieldRemark=isnull(g.[value],'')--字段说明 FROM syscolumns a left join systypes b on a.xtype=b.xusertype inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' left join syscomments e on a.cdefault=e.id left join sys.extended_properties g on a.id=g.major_id and a.colid=g.minor_id--sql2005 --left join sysproperties g on a.id=g.id and a.colid=g.smallid where d.name='TableName' order by a.id,a.colorder
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。