首页 > 代码库 > 查询sql2005&2008全部表信息
查询sql2005&2008全部表信息
1 如果是查询sql server 2000,把sys.extended_properties修改为SysProperties 2 3 SELECT 4 表名 = CASE WHEN A.COLORDER=1 THEN D.NAME ELSE ‘‘ END, 5 表说明 = CASE WHEN A.COLORDER=1 THEN ISNULL(F.VALUE,‘‘) ELSE ‘‘ END, 6 列序号 = A.COLORDER, 7 列名 = A.NAME, 8 标识 = CASE WHEN COLUMNPROPERTY( A.ID,A.NAME,‘ISIDENTITY‘)=1 THEN ‘√‘ELSE ‘‘ END, 9 主鍵 = CASE WHEN EXISTS(SELECT 1 FROM SYSOBJECTS WHERE XTYPE=‘PK‘ AND PARENT_OBJ=A.ID AND NAME IN (10 SELECT NAME FROM SYSINDEXES WHERE INDID IN(11 SELECT INDID FROM SYSINDEXKEYS WHERE ID = A.ID AND COLID=A.COLID))) THEN ‘√‘ ELSE ‘‘ END,12 类型 = B.NAME,13 字节数 = A.LENGTH,14 长度 = COLUMNPROPERTY(A.ID,A.NAME,‘PRECISION‘),15 小数位数 = ISNULL(COLUMNPROPERTY(A.ID,A.NAME,‘SCALE‘),0),16 允许空 = CASE WHEN A.ISNULLABLE=1 THEN ‘√‘ELSE ‘‘ END,17 默认值 = ISNULL(E.TEXT,‘‘),18 字段说明 = ISNULL(G.[VALUE],‘‘)19 FROM 20 SYSCOLUMNS A21 LEFT JOIN 22 SYSTYPES B 23 ON 24 A.XUSERTYPE=B.XUSERTYPE25 INNER JOIN 26 SYSOBJECTS D 27 ON 28 A.ID=D.ID AND D.XTYPE=‘U‘ AND D.NAME<>‘DTPROPERTIES‘29 LEFT JOIN 30 SYSCOMMENTS E 31 ON 32 A.CDEFAULT=E.ID33 LEFT JOIN 34 sys.extended_properties G 35 ON 36 A.ID=G.major_id AND A.COLID=G.minor_id 37 LEFT JOIN 38 sys.extended_properties F 39 ON 40 D.ID=F.major_id AND F.minor_id=041 ORDER BY 42 A.ID,A.COLORDER
查询sql2005&2008全部表信息
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。