#1
  1. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Jan 2004
    Location
    Houston
    Posts
    407
    Rep Power
    11

    Need Quick Education On SQL Bit Field...


    I'm just making sure that I'm using a bit field correctly..

    in SQL Server, my first question IS :
    The Bit field is looking for a value of?

    My 1st assumption is 1 or 0 right? 1 = true, 0=false?

    Second, when updating the fields with an SQL update or insert, you just simply set it to 1 or 0?

    somebitfield=1 -- and not somebitfield='1' or somebitfield='true'?

    Also, for future reference... when I first created these bit fields in an existing table, i ran into the problem that as I had exisitng records, and a bit field does not allow a null, it wouldn't let me create the field as they were empty.. so I first made them varchar, entered a 1 into each column(i only have 5 test records at the moment) and then went back and changed em to a bit field. Surely there has to be a way around that???

    THankx, happy easter everyone!
  2. #2
  3. No Profile Picture
    dip
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2004
    Posts
    11
    Rep Power
    0

    hi


    Hello plasma,
    Q:The Bit field is looking for a value of?
    A:either a 1 or a 0.

    Q:when updating the fields with an SQL update or insert, you just simply set it to 1 or 0?
    A:Valid somebitfield=1 and not somebitfield='1'
    InValid somebitfield='true'

    Sorry i cant say much about your 'future reference'. i will getback u after some time


    Desc about bit :
    Consists of either a 1 or a 0. Use the bit data type when representing TRUE or FALSE, or YES or NO. For example, a client questionnaire that asks if this is the client's first visit can be stored in a bit column

    waiting 4 your kind response
    dipit
  4. #3
  5. No Profile Picture
    dip
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2004
    Posts
    11
    Rep Power
    0

    Thumbs up hello


    hi
    i wait some more info and i wait you to check this,

    Also, for future reference... when I first created these bit fields in an existing table Which data type it was , i ran into the problem that as I had exisitng records, and a bit field does not allow a null Sorry, but if allows. it allow 1,0,null, it wouldn't let ......!!!!!!!!!!!!!!!!!!

    dipit
  6. #4
  7. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Jan 2004
    Location
    Houston
    Posts
    407
    Rep Power
    11
    For instance, say we have an existing table with 10 rows..

    and now you need to add a bit field to make some true or false decision about that record when called..

    If you now went and created that bit field, enterprise manage gets pissed.. cause it doesnt allow nulls, but tries to add the bit field to each record.. but of course has no idea what to fill it with..

    is there a way to tell Ent Manager, to go ahead and fill each field with either a one or a zero.. and then you can put forth the effort of making each correct...
  8. #5
  9. Unholy Moderator
    ASP Mastermind (5000+ posts)

    Join Date
    Oct 2003
    Location
    In hell, where did you think?
    Posts
    12,026
    Rep Power
    658
    To get around the problem of creating a bit field after the fact, you need to set a default value to the bit field when you create it, usually 0. Then it will work.

Similar Threads

  1. Cannot establish a connection to SQL Server 2K sp3a remotely
    By ngandy in forum Microsoft SQL Server
    Replies: 6
    Last Post: January 19th, 2005, 02:54 AM
  2. SQL Statement Case selection...
    By plasma800 in forum SQL Development
    Replies: 1
    Last Post: May 4th, 2004, 05:13 AM
  3. Simple combo box/text box issue, difficult description (part 1)
    By etalent in forum Microsoft Access Help
    Replies: 1
    Last Post: March 29th, 2004, 05:16 PM
  4. Replies: 8
    Last Post: March 26th, 2004, 10:23 AM
  5. insert query
    By jamesjohn in forum ASP Development
    Replies: 1
    Last Post: March 17th, 2004, 11:36 PM

IMN logo majestic logo threadwatch logo seochat tools logo