I'm designing a SQL datbase table and a couple of the columns need to hold either a 1 or 0 (true or false). I define the columns to be of type binary(1), but now I don't know how to insert a true or false value into the database. inserting "true" or "1" doesn't work (it says either int or bool cannot be converted to binary)...
+6
A:
Use the bit
data type instead for your column. Then you can insert true/false directly.
klausbyskov
2010-09-14 13:56:01
Sounds good. Now, what is the binary data type? I thought binary meant 0 or 1.
Soo
2010-09-14 13:57:00
binary allows you to store raw data, such as images or word documents. well anything really...
klausbyskov
2010-09-14 13:58:36
Huh, interesting. I'll have to learn more about that some time. Thanks!
Soo
2010-09-14 13:59:41
+1
A:
This depends on what database you are using. E.g., for SQL Server you can use bit and then set it to true using an integer 1. For Access, you can use a boolean and set it to True/False.
RedFilter
2010-09-14 13:56:23
+1
A:
Since there there is no Boolean in SQL server you can just use bit
and set it to 0/1
Iulian
2010-09-14 13:56:50