zoukankan      html  css  js  c++  java
  • 方便查看数据表和字段的SQL语句(适用于SQLServer2000)


      经过对SQLServer2000系统表的分析,写出了以下两个SQL语句。可以把这两个语句分别建为两个“视图”,方便查看用户数据表和字段的信息。

    1、列出所有的用户数据表:

    SELECT TOP 100 PERCENT o.name AS 表名
    FROM dbo.syscolumns c INNER JOIN
          dbo.sysobjects o ON o.id = c.id AND objectproperty(o.id, N'IsUserTable') = 1 AND
          o.name <> 'dtproperties' LEFT OUTER JOIN
          dbo.sysproperties m ON m.id = o.id AND m.smallid = c.colorder
    WHERE (c.colid = 1)
    ORDER BY o.name, c.colid


    2、列出所有的用户数据表及其字段信息:

    SELECT TOP 100 PERCENT c.colid AS 序号, o.name AS 表名, c.name AS 列名,
          t.name AS 类型, c.length AS 长度, c.isnullable AS 允许空,
          CAST(m.[value] AS Varchar(100)) AS 说明
    FROM dbo.syscolumns c INNER JOIN
          dbo.sysobjects o ON o.id = c.id AND objectproperty(o.id, N'IsUserTable') = 1 AND
          o.name <> 'dtproperties' INNER JOIN
          dbo.systypes t ON t.xusertype = c.xusertype LEFT OUTER JOIN
          dbo.sysproperties m ON m.id = o.id AND m.smallid = c.colorder
    ORDER BY o.name, c.colid


    你如果有更好的方法,请交流一下:)

    ----作者:夏春涛 Email:xChuntao@163.com  QQ:23106676 ----



  • 相关阅读:
    poj 2029 Get Many Persimmon Trees 夜
    poj 1191 棋盘分割 夜
    DOM (四)
    div拖拽, onmousedown ,onmousemove, onmouseup
    闭包理解
    DOM(一)
    内存溢出与内存泄漏
    div随鼠标移动而移动(滚动条)
    对象继承模式
    DOM(二)
  • 原文地址:https://www.cnblogs.com/SummerRain/p/685783.html
Copyright © 2011-2022 走看看