To generate a SQL Server data dictionary by using an SQL statement ^

Source: Internet
Author: User
Tags join table name
server|sqlserver| Data | Statement SELECT table name =case when a.colorder=1 then D.name else ' "End,
--Field ordinal =a.colorder,
Field name =a.name,
--Identify =case when ColumnProperty (A.id,a.name, ' isidentity ') =1 then ' √ ' Else ' "end,
/* Primary key =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 = a.id and colid=a.colid))
Then ' √ ' Else ' end,
*/
Type =b.name,
--Takes up bytes of =a.length,
Length =columnproperty (a.id,a.name, ' PRECISION '),
Decimal Places =isnull (ColumnProperty (a.id,a.name, ' Scale '), 0),
Allow empty =case when a.isnullable=1 then ' √ ' Else ' end,
Default value =isnull (E.text, ""),
Field Description =isnull (G.[value], "")
From syscolumns a LEFT join systypes B on a.xtype=b.xusertype inner join sysobjects D on a.id=d.id
and D.xtype= ' U ' and d.name<> ' dtproperties '
Left join syscomments E on a.cdefault=e.id left join Sysproperties G on a.id=g.id
and A.colid=g.smallid
ORDER BY A.id,a.colorder

Related Article

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.