-
SQL Server and Boolean
We just used the Data Transformation Wizard to convert an Access DB into SQL Server 7. I see that boolean values were converted to integers (0,1). Now, we're ready to convert the VB code supporting the DB.
This code fails:
"INSERT INTO tblMyTable (blnField) VALUES (False);"
This code works:
"INSERT INTO tblMyTable (blnField) VALUES (0);"
I understand this ok, but when I read a value from the new table, it allows me to read the field as T/F, thus...
This code works:
If !blnField Then...
How come? Am I doing something wrong? Does anyone have any suggestions? This is a big app and the less code converting I have to do, the happier I'll be.
Thanks,
Jeff
-
This just looks like a product of the way that VB does a Boolean check. It implicitly converts your data, and all non-zero values are True; zero = False.
BTW SQL Server has a Bit datatype which takes 0 or 1, so it behaves very similarly to an Access Yes/No field (0, -1). I think it's a quarter of the size of an int.