Query sql2005&2008 all table information

Source: Internet
Author: User

1If you are querying SQL Server -, change the sys.extended_properties to Sysproperties2 3 SELECT 4Table name=  Case  whenA.colorder=1  ThenD.nameELSE "' END,5Table description=  Case  whenA.colorder=1  Then ISNULL(F.value,"')ELSE "' END,6Column ordinal=A.colorder,7Column Name=A.name,8Identity=  Case  when ColumnProperty(A.id,a.name,'isidentity')=1  Then '√'ELSE "' END,9Main keys=  Case  when EXISTS(SELECT 1  fromSYSOBJECTSWHEREXTYPE='PK'  andParent_obj=a.ID andNAMEinch (Ten SELECTNAME fromsysindexesWHEREIndidinch( One SELECTIndid fromSysindexkeysWHEREId=a.ID andCOLID=A.colid))) Then '√' ELSE "' END, AType=B.name, -Number of bytes=A.length, -Length= ColumnProperty(A.id,a.name,'PRECISION'), theNumber of decimal digits= ISNULL(ColumnProperty(A.id,a.name,' Scale'),0), -Allow empty=  Case  whenA.isnullable=1  Then '√'ELSE "' END, -Default value= ISNULL(E.TEXT,"'), -Field description= ISNULL(G.[VALUE],"') +  from  - syscolumns A +  Left JOIN  A systypes B at  on  -A.xusertype=B.xusertype - INNER JOIN  - SYSOBJECTS D -  on  -a.ID=D.id andD.xtype='U'  andD.name<>'dtproperties' in  Left JOIN  - syscomments E to  on  +A.cdefault=e.id -  Left JOIN  the sys.extended_properties G *  on  $a.ID=g.major_id andA.colid=g.minor_idPanax Notoginseng  Left JOIN  - sys.extended_properties F the  on  +D.id=f.major_id andf.minor_id=0 A ORDER  by  theA.id,a.colorder

Query sql2005&2008 all table information

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.