Results 1 to 2 of 2

Thread: SQL Server and Boolean

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82

    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

  2. #2
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width