Of course, the first reaction is to use stored procedures. Determine the original field value and then UPDATE it.
I cannot find a solution after a rough query on the Internet. I have a very interesting result, and I don't even need to use WHERE.
Assign values to the BIT type of the database. use SQL statements to operate the database and use the management interface to input different values. The management interface must be set to TRUE or FALSE. SQL statements use 0 or 1
Therefore, first try:
Copy codeThe Code is as follows:
Updat t set B = B + 1 where id = 1;
Select B from t where id = 1;
Field B remains 1
So what about using minus signs?
Copy codeThe Code is as follows:
Update t set B = B-1 where id = 1;
Select B from t where id = 1;
We can find that each result is switched between 0 and 1, and SQL SERVER treats-1 as 1.
This requirement can be easily solved.
This is usually used in some status switches (or switches). You do not need to know the status after the switch. Very interesting and simple.