Requirement: Use a SQL (SQL SERVER) statement to implement a value that reverses the State identity field (type bit). That is, from true to false, or from false to true.
Scheme:
First, determine the original value of this field, and then update to the opposite value.
Second, to the database bit type assignment, in the management interface input and the use of SQL statement to operate a different . The admin interface input must be true or FALSE, and the SQL statement will be 0 or 1.
Practice:
UPDATE attusers SET IsActive =isactive+1 WHERE id=1
SELECT * from Attusers WHERE id=1
IsActive Field remains 1
What if we use a minus sign? Practice:
UPDATE attusers SET IsActive =isactive-1 WHERE id=1
SELECT * from Attusers WHERE id=1
You can find that each time the result is switched between 0 and 1, SQL Server handles 1 as one.
SQL Toggle True/False Status Identification field