The use of SQL SERVER INFORMATION_SCHEMA

Source: Internet
Author: User

-------------------------------------------------------the first query to see how many tables in the library, table names, and so on select * from INFORMATION_SCHEMA. TABLES;-------------------------------------------------------the second query searches for a detailed SELECT (case a.colorder=1 then D.name Else ' end ' as table name,--returns an empty a.colorder as field ordinal if the table name is the same, a.name as field name (case when ColumnProperty (A.id,a.nam                       E, ' isidentity ') =1 then ' √ ' else ' end as identifier (case when (SELECT count (*) from sysobjects--query primary key where (name in (the SELECT name from sysindexes WHERE (id = A.I                                         d) and (Indid in (SELECT indid from Sysindexkeys                                           WHERE (id = a.id) and (Colid in (SELECT colid from syscolumns  WHERE (id = a.id) and (name = A.name)))))) and (xtype = ' PK ')) >0 then ' √ ' else ' end as primary key,--Query primary key end B.name as type, a.length as takes up bytes, columnproperty (a.id,a.name, ' PRECISION ') as length, IsNull (ColumnProperty (a). Id,a.name, ' scale '), 0) as decimal digits, (case time a.isnullable=1 then ' √ ' else ' end) as allows null, ISNULL (E.text, ") as default, Isnu    LL (G.[value], ') as field description 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 joins syscomments E on a.cdefault=e.id left join S Ys.extended_properties g on a.id=g.major_id and a.colid = g.minor_id ORDER by A.id,a.colorder

The use of SQL SERVER INFORMATION_SCHEMA

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.