SQL Server queries database all fields-table name

Source: Internet
Author: User
Tags joins

SELECT * from Information_schema.columns WHERE table_name= ' account ' SELECT if A.colorder=1 then d.name Else ' E nd) as table name,--if the table name is the same, return the empty a.colorder as field ordinal, a.name as field name, (case when ColumnProperty (A.id,a.name, ' Isiden Tity ') =1 then ' √ ' Else ' End as identity, (case if (SELECT count (*) from sysobjects--query primary key WHERE ( Name in (the SELECT name from sysindexes WHERE (id = a.id) and ( Indid in (SELECT indid from Sysindexkeys WHE                                           RE (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 place (case time a.isnullable=1 then ' √ ' else ' end) as allows null, ISNULL (E.text, ") as Default value, IsNull (G.[value], ') as field description from syscolumns a LEFT join systypes B on a.xtype=b.xusertype inner join SYSOB   Jects D on A.id=d.id and d.xtype= ' U ' and d.name<> ' dtproperties ' left joins syscomments E on a.cdefault=e.id Left joins Sys.extended_properties G on a.id=g.major_id and a.colid = g.minor_id ORDER by A.id,a.colorder querying all table names in the database and field name statement SQL query all table names: select name from SYSOBJECTS WHERE type= ' U ' SELECT * from INFORMATION_SCHEMA. Tables all field names of the query table: select name from syscolumns WHERE id=object_id (' Table name ') SELECT * from INFORMATION_SCHEMA. Tablesselect * from INFORMATION_SCHEMA. Viewsselect * from INFORMATION_SCHEMA. Columnsoracle View all table names: Select table_name from user_tablesaccess View all table names: select name from Msysobjects WHERE type=1 and Flags=0 Msysobjects is a system object, which is hidden by default. It can be displayed by tools, options, views, displays, system objects, and so on.

  

SQL Server queries database all fields-table name

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.