您的位置:首页 > 数据库

查看SQLServer数据表的详细信息。

2008-04-27 06:33 459 查看
SELECT
表名=casewhena.colorder=1thend.nameelse''end,
表说明=casewhena.colorder=1thenisnull(f.value,'')else''end,
字段序号=a.colorder,
字段名=a.name,
标识=casewhenCOLUMNPROPERTY(a.id,a.name,'IsIdentity')=1then'√'else''end,
主键=casewhenexists(SELECT1FROMsysobjectswherextype='PK'andnamein(
SELECTnameFROMsysindexesWHEREindidin(
SELECTindidFROMsysindexkeysWHEREid=a.idANDcolid=a.colid
)))then'√'else''end,
类型=b.name,
占用字节数=a.length,
长度=COLUMNPROPERTY(a.id,a.name,'PRECISION'),
小数位数=isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0),
允许空=casewhena.isnullable=1then'√'else''end,
默认值=isnull(e.text,''),
字段说明=isnull(g.[value],'')
FROMsyscolumnsa
leftjoinsystypesbona.xtype=b.xusertype
innerjoinsysobjectsdona.id=d.id andd.xtype='U'and d.name<>'dtproperties'
leftjoinsyscommentseona.cdefault=e.id
leftjoinsyspropertiesgona.id=g.idanda.colid=g.smallid
leftjoinsyspropertiesfond.id=f.idandf.smallid=0
--whered.name='要查询的表' --如果只查询指定表,加上此条件
orderbya.id,a.colorder
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: