MSSQL Gets the database field type

Source: Internet
Author: User

1 SELECT2Col.name ascolumn name,3Typ.name asdata type,4Col.max_length asthe number of bytes consumed,5Col.Precision  asnumber length,6Col.scale asNumber of decimal digits,7Col.is_nullable aswhether to allow non-null,8Col.is_identity asis it self-increasing,9     Case  when exists Ten(SELECT 1  One          from  A sys.indexes idx -             Joinsys.index_columns Idxcol -              on(idx.)object_id =Idxcol.object_id) the          WHERE -Idx.object_id =Col.object_id -              andidxcol.index_column_id=col.column_id -              andIdx.is_primary_key= 1 +) Then 1 ELSE 0 END   asis the primary key, -   IsNull(Prop.[value],'-') asDescription +  from A sys.columns Col at      Left Joinsys.types Typ -        on(col.system_type_id=typ.system_type_id) -      Left JoinSys.extended_properties prop -        on(Col.object_id =prop.major_id andprop.minor_id=col.column_id) - WHERE -Col.object_id = in(SELECT object_id  fromSys.tablesWHEREName= 'band')

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.