SQL Server Data Type traps

Source: Internet
Author: User

1.

Bit type: bit (1) don't think it's just a bit, in fact it's going to take up a byte! That means when n < 8 o'clock is like this!

2.

varchar (n) here n cannot be greater than 8000, if you want to be larger than 8000 you can only specify varchar (max); Here's the same for nvarchar (n).

What I don't understand is why 8000 is not 2 of the 16-time party! Why Max can be infinitely big!

3.

Sql_variant can think of it as an object type in C#/java, that is to say what objects can exist inside, attention is also required, objects can not exceed 8000 bytes!

Don't think you know this is no matter, there are many things!

Example:

CREATE table t (x sql_variant);

INSERT into t (x) values (1234); can perform

INSERT into t (x) VALUES (' ABCD '); can perform

INSERT into t (x) VALUES (1234), (' ABCD '); You cannot execute the hint "failed while converting varchar value ' ABCD ' to data type int"

4.

FileStream table to have a column of uniqueidentifier columns, and requires that it is not NULL, unique!

SQL Server Data Type traps

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.