Saving boolean values ​​in SQL?

I am developing a datbase SQL table, and a pair of columns should contain either 1 or 0 (true or false). I define columns of type binary (1), but now I do not know how to insert the value true or false into the database. inserting "true" or "1" does not work (this says int or bool cannot be converted to binary) ...

+6
c # sql
source share
4 answers

Use the bit data type instead for your column. Then you can directly insert true / false.

+20
source share

Use bit

This takes the strings true and false.

It also maps directly to the C # boolean type, which is useful

+5
source share

Since there is no logical in the SQL server, you can just use bit and set it to 0/1

+3
source share

It depends on which database you are using. For example, for SQL Server, you can use a bit and then set it to true using the integer 1. For Access, you can use a boolean and set it to True / False.

+1
source share

All Articles