What is the best practice for creating a yes/no
i.e. Boolean
field when converting from an access database
or in general?
In SQL Server, a Boolean Datatype can be created by means of keeping BIT datatype. Though it is a numeric datatype, it can accept either 0 or 1 or NULL values only. Hence easily we can assign FALSE values to 0 and TRUE values to 1. This will provide the boolean nature for a data type.
You can update boolean value using UPDATE command. If you use the BOOLEAN data type, MySQL internally convert it into tinyint(1). It can takes true or false literal in which true indicates 1 to tinyint(1) and false indicates 0 to tinyint(1).
There is boolean data type in SQL Server. Its values can be TRUE , FALSE or UNKNOWN . However, the boolean data type is only the result of a boolean expression containing some combination of comparison operators (e.g. = , <> , < , >= ) or logical operators (e.g. AND , OR , IN , EXISTS ).
The equivalent is a BIT
field.
In SQL
you use 0
and 1
to set a bit field (just as a yes/no field in Access). In Management Studio it displays as a false/true value (at least in recent versions).
When accessing the database through ASP.NET it will expose the field as a boolean value.
The BIT
datatype is generally used to store boolean
values (0
for false
, 1
for true
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With