SQL Server FETCH statement for table structure

Source: Internet
Author: User

SQL Server 2008 Fetch method:--------------------------------------- SELECT      Table name = case when a.colorder=1 Then D.name else ' end,      Table Description = case when a.colorder=1 then IsNull (F.value, ') Else ' end,      Field ordinal = a.colorder,      Field name = a.name,      Field description = IsNull (G.[value], '),    &N BSP; identity = case when ColumnProperty (A.id,a.name, ' isidentity ') =1 Then ' √ ' Else ' end,      PRIMARY key = case when Exis TS (SELECT 1 from sysobjects Where xtype= ' PK ' and Parent_obj=a.id and name in (            &N Bsp         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,      Number of bytes occupied = a.length,      length = ColumnProperty (a.id,a.name, ' PRECISION '),      number of decimal digits = IsNull (ColumnProperty (A.id,a.name, ' Scale '), 0),     Allow NULL = case time a.isnullable=1 Then ' √ ' Else ' end,      default = IsNull (E.text, ')  from syscolumns a&nbsp ; Left joins Systypes B on A.xusertype=b.xusertype inner joins sysobjects D on a.id=d.id and d.xtype= ' U ' and D.NAME<&G t; ' Dtproperties '  left join syscomments E on A.cdefault=e.id left join Sys.extended_properties G on A.id=G.major_ ID and A.colid=g.minor_id left Join sys.extended_properties F on d.id=f.major_id and F.minor_id=0 where D.name = ' Person '  order by a.id,a.colorder 

SQL Server FETCH statement for table structure

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.