Mssql database document generation

Source: Internet
Author: User
  1. Sqls 2000
    Title

    Select d. Name as TableName, A. colorder AS ColOrder, A. name AS Name,
    COLUMNPROPERTY (A. ID, A. Name, 'isidentity ') AS IsIdentity,
    CASE WHEN EXISTS
    (SELECT 1
    FROM dbo. 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 1 ELSE 0 end as primary key,
    B. name AS type,
    A. length AS [length],
    A. xprec AS [precision],
    A. xscale AS [decimal],
    Case when a. isnullable = 1 THEN 1 ELSE 0 end as [can be empty],
    ISNULL (E. text, '') AS [default value],
    ISNULL (G. [value], '') AS [description]
    FROM dbo. syscolumns A LEFT OUTER JOIN
    Dbo. policypes B on a. xtype = B. xusertype INNER JOIN
    Dbo. sysobjects d on a. id = D. id and d. xtype = 'U' AND
    D. name <> 'dtproperties' LEFT OUTER JOIN
    Dbo. syscomments e on a. cdefault = E. id LEFT OUTER JOIN
    Dbo. sysproperties g on a. id = G. id and a. colid = G. smallid
    -- Where d. Name = 'tablename' -- if you are looking for a specified table, remove the comment.
    Order by 1, 2

  2. Sqls 2005
    Select d. Name as TableName, A. colorder AS ColOrder, A. name AS Name,
    COLUMNPROPERTY (A. ID, A. Name, 'isidentity ') AS IsIdentity,
    CASE WHEN EXISTS
    (SELECT 1
    FROM dbo. 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 1 ELSE 0 end as primary key,
    B. name AS type,
    A. length AS [length],
    A. xprec AS [precision],
    A. xscale AS [decimal],
    Case when a. isnullable = 1 THEN 1 ELSE 0 end as [can be empty],
    ISNULL (E. text, '') AS [default value],
    ISNULL (G. [value], '') AS [description]
    FROM dbo. syscolumns A LEFT OUTER JOIN
    Dbo. policypes B on a. xtype = B. xusertype INNER JOIN
    Dbo. sysobjects d on a. id = D. id and d. xtype = 'U' AND
    D. name <> 'dtproperties' LEFT OUTER JOIN
    Dbo. syscomments e on a. cdefault = E. id LEFT OUTER JOIN
    Sys. extended_properties g on a. id = G. major_id and a. colid = G. minor_id
    Where d. Name = 'suspect '-- if you are looking for a specified table, remove the comment.
    Order by 1, 2
  3. Gadgets
    /Files/skyangell/sqldoc_src.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.