Sqlserver obtains the type and number of bytes of the names and column names of all tables in the database.

Source: Internet
Author: User

obtain the type and number of bytes of the names and column names of all tables in the database.

  select  
. name as table name,
B. name as column name,
C. name as type,
B. max_length as ,
B. precision as integer,
B. scale as decimal places
from sys. tables A
Inner join sys. columns B On . object_id = B. object_id
Inner join sys. types
C On C. user_type_id = B. user_type_id

In which table can we query detailed information such as the type of the field?

 Select 
A. Name As Table Name,
B. Name As Column name,
C. Name As Type,
B. max_length As Number of bytes,
B. Precision As Integer,
B. Scale As Decimal places
From SYS. Tables
Inner Join SYS. columns B On A. Object_id = B. Object_id
Inner Join SYS. Types
C On C. user_type_id = B. user_type_id Where A. Name = ' Table Name ' And B. Name = ' Column name '

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.