Get table structure in SQL Server2008 with SQL

Source: Internet
Author: User

Get table structure in SQL Server2008 with SQL


New data user, the role is public. Mapped to the database on which the table structure is to be obtained, granting the user's identity on the database as db_owner


Run SQL statements such as the following:

Select Syscolumns.name as [name], systypes.name as [type],syscolumns.length as [Size],syscolumns.xprec as [Precision], is Null (Syscolumns.scale, 0) as [scale],sys.extended_properties.value as [mark],syscolumns.isnullable as [NULL], (case When exists (select 1 from sysobjects inner joins sysindexes on sysindexes.name = sysobjects.name INNER JOIN Sysindexkeys On sysindexes.id = sysindexkeys.id and Sysindexes.indid = sysindexkeys.indid where xtype= ' PK ' and parent_obj = Syscolumn S.id and sysindexkeys.colid = syscolumns.colid) then 1 else 0 end) as [PK], (case syscolumns.status when 1 els e 0 end) as [Identity] from syscolumns inner join systypes on (Syscolumns.xtype = Systypes.xtype and Systypes.name & Lt;> ' _default_ ' and systypes.name<> ' sysname ') left outer join sys.extended_properties on (sys.extended_pro Perties.major_id=syscolumns.id and minor_id=syscolumns.colid) where syscolumns.id = (select id from sysobjects where Name= ' Nds_tfileform ') Order BYSyscolumns.colid 

Get table structure in SQL Server2008 with SQL

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.