Find field property information in SQL data tables or views

Source: Internet
Author: User

One, only support the table, very good

SELECT A.name, ( CaseWhen (SELECT count (*) from sysobjects WHERE (nameinch(SELECT name from sysindexes WHERE (id =a.id) and (Indidinch(SELECT indid from Sysindexkeys WHERE (id =a.id) and (Colidinch(SELECT colid from syscolumns WHERE (id = a.id) and (name = A.name))))))) and (Xtype ='PK')) >0Then'1' Else '0'end) Isprimary,b.name [Type],columnproperty (A.id,a.name,'PRECISION') as[Length],isnull (G.value,"') as[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 join syscomments e on A.cdefault=e.id left joins Sys.extended_properties G on a.id=g.major_id and a.colid =g.minor_idwhereD.name ='indicate that'ORDER BY A.id,a.colorder

Second, general cool, support table

Select  as  as  as   from syscolumns c inner joins systypes T on c.xusertype=where objectproperty (c.id, ' isusertable ') =1 and c.id=object_id (' indicate ')

Three, general cool, support view

Select  as  as  as length    from syscolumns c inner joins systypes T on c.xusertype=where objectproperty (c.id,' C10>isview') =1 and c.id=object_id ('v_allsay' )

Ask the big God very well. Supports both table and view-supported SQL

Find field property information in SQL data tables or views

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.