Get the classic SQL statement for MS SQL Library data Dictionary

Source: Internet
Author: User
Data | statement

SELECT sysobjects.name as [table], sysproperties. [Value] As table description,
Syscolumns.name as field, properties. [Value] As field description, Systypes.name as type,
Syscolumns.length, ISNULL (ColumnProperty (syscolumns.id, Syscolumns.name,
' Scale '), 0 as decimal places, syscolumns.isnullable as IsNull,
Case when Syscomments.text is NULL
THEN ' ELSE syscomments.text end as [Default],
Case when ColumnProperty (Syscolumns.id, Syscolumns.name, ' isidentity ')
= 1 THEN ' √ ' ELSE ' end as logo, 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 = syscolumns.id and colid = Syscolumns.colid))
THEN ' √ ' ELSE ' end as primary key
From syscolumns INNER JOIN
sysobjects on sysobjects.id = syscolumns.id INNER JOIN
systypes on syscolumns.xtype = Systypes.xtype left OUTER JOIN
Sysproperties properties on syscolumns.id = Properties.id and
Syscolumns.colid = Properties.smallid Left OUTER JOIN
Sysproperties on sysobjects.id = Sysproperties.id and
Sysproperties.smallid = 0 Left OUTER JOIN
syscomments on syscolumns.cdefault = syscomments.id
WHERE (sysobjects.xtype = ' U ')




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.