April 11th, 2004, 12:41 PM
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!
April 11th, 2004, 11:52 PM
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'
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
April 12th, 2004, 12:05 AM
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 ......!!!!!!!!!!!!!!!!!!
April 12th, 2004, 12:36 AM
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...
April 12th, 2004, 09:12 AM
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.