|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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... |
|
#5
|
||||
|
||||
|
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.
|
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Need Quick Education On SQL Bit Field... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|