MSSQL use SQL statements to quickly see the description of table pairs, and table field descriptions and fields types

Source: Internet
Author: User
Tags mssql

--Table DescriptionSELECTtbs.name table name, ds.value description fromsys.extended_properties DS Left JOINsysobjects TBS onds.major_id=tbs.idWHEREds.minor_id=0  andTbs.name='Warrant_baseinfo';--Table name  --Quick View Table structureSELECT   Case  whenCol.colorder= 1  ThenObj.nameELSE "'               END  astable name, Col.colorder asserial number, Col.name ascolumn name,ISNULL(ep.[value],"') ascolumn description, T.name asdata type, Col.length aslength,ISNULL(ColumnProperty(Col.id, Col.name,' Scale'),0) asNumber of decimal digits, Case  when ColumnProperty(Col.id, Col.name,'isidentity')= 1  Then '√'               ELSE "'          END  asidentification, Case  when EXISTS(SELECT   1                              fromdbo.sysindexes siINNER JOINDbo.sysindexkeys Sik onSi.id=sik.id andSi.indid=Sik.indidINNER JOINDbo.syscolumns SC onSc.id=sik.id andSc.colid=Sik.colidINNER JOINDbo.sysobjects so onSo.name=Si.name andSo.xtype= 'PK'                             WHERESc.id=col.id andSc.colid=Col.colid) Then '√'               ELSE "'          END  asprimary KEY, Case  whenCol.isnullable= 1  Then '√'               ELSE "'          END  asallow NULL,ISNULL(Comm.text,"') asDefault Value fromDbo.syscolumns Col Left  JOINDbo.systypes T onCol.xtype=T.xusertypeInner JOINDbo.sysobjects obj onCol.id=obj.id andObj.xtype= 'U'                                            andObj.status>= 0           Left  JOINDbo.syscomments Comm onCol.cdefault=comm.id Left  JOINSys.extended_properties EP onCol.id=ep.major_id andCol.colid=ep.minor_id andEp.name= 'ms_description'           Left  JOINSys.extended_properties Eptwo onObj.id=eptwo.major_id andeptwo.minor_id= 0                                                            andEptwo.name= 'ms_description'  WHEREObj.name= 'Ath_loanapply_tbl'--Table nameORDER  byCol.colorder;

Turn from here: http://blog.csdn.net/lqh4188/article/details/39225191

MSSQL use SQL statements to quickly see the description of table pairs, and table field descriptions and fields types

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.