Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
macca18
Starting Member
7 Posts |
Posted - 2006-05-09 : 08:39:14
|
| Hi,I am trying to implement a boolean field in my SQL 2005 database. I've read some newsgroups saying that there is no boolean type but instead a bit type is used.When I try to input a Query with a boolean valueI get the error :-"The name "True" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted."I declare my var as Boolean Present = true;I then put the prsesnt var into my query and my query will end up looking like :-INSERT Users VALUES(1, 'John', 'Doe', 'Supervisor', True);Does anyone know why this is wrong?I've also noticed people using char(1) and using Y/N or T/F.Can anyone give me advice on which is the best method?Thanks In AdvanceMacca |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-09 : 08:43:10
|
| Instead of True supply non zero valueMadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-09 : 08:44:04
|
define your table column as bituse 1 for TRUE and 0 for FALSE KH |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-05-09 : 08:54:13
|
| +1 khtan, faster evaluation compared to character type--------------------keeping it simple... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-09 : 08:56:14
|
My answer is based on bit datatype and not char MadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-09 : 09:00:51
|
+1 for Madhivanan for non zero value as TRUE  KH |
 |
|
|
PSamsig
Constraint Violating Yak Guru
384 Posts |
Posted - 2006-05-10 : 02:09:49
|
| This is the second time in a short while somebody asks this, could it be that SSMSs table 'Open table' views (where you can modify table contence) actually uses 'True'/'False' for bit fields ?`(which is HIGHLY annoying ... more typing).--This one's tricky. You have to use calculus and imaginary numbers for this. You know, eleventeen, thirty-twelve and all those. |
 |
|
|
|
|
|
|
|