bit type field in SQL Server Delete and change the thing.

Source: Internet
Author: User

Tag: The code type will also query src update image creat BSP

  

The bit Type field before the first look at the "weird" scene, to perform the update successfully, but the results of the query is still 1, not the update of 2
When others asked me to come, I was also in a state of confused, behind Lenovo specific business suddenly remembered that this field is a bit type

  

It is not surprising that this phenomenon is contiguous with the bit Type field.
Not much nonsense, directly on the code to see the result is good.
Build a test table first

CREATE TABLE testbit (    INTIDENTITY(1,1),    BIT) 

As a rule, the bit Type field can only be 0 or 1, so direct inert 0 or 1 is of course no problem.

Because bit is a true or false value, it is not a problem to assign the string to False or true at insert time.

Of course the text only supports false or true of the two strings, the other will be error, from the error will also be found in the insert when there is an implicit conversion

For numeric data: When execution inserts a value other than 0 or 1, it is inserted successfully, but the value of the insertion (not 0) is implicitly converted to 1.
Inserting a value other than 0 is converted to 1, which is true

The update is the same if the update is a numeric value, the updated string can only be false or True

   

If the update is a numeric value and the value is not 0 (integer or negative), it is equivalent to updating the bit field type to 1

  

bit type field in SQL Server Delete and change the thing.

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.