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 |
|
cristy
Starting Member
2 Posts |
Posted - 2006-05-23 : 10:32:51
|
| Hello,I have columns defined as BIT data type. I need to add these columns and do some calculations with the totals. I've search the Online Help and couldn't find anything.Do you convert BIT into INT and then do your calculation? Anyone have an example of this? Thanks so much.Cristy |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-23 : 10:38:21
|
| Bit column stores 0,1 or NULL. What do you want to do with that?declare @i int, @b bitselect @i=1, @b=1select @i+@bPost some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-23 : 10:39:31
|
Just add it as an integer but take note that bit data type only have value of 0 or 1.create table #temp( col1 bit)insert into #tempselect 0 union allselect 1 union allselect 2select col1 + 1from #temp/* RESULTcol1122*/ KH |
 |
|
|
cristy
Starting Member
2 Posts |
Posted - 2006-05-23 : 10:50:45
|
| In the form, these bit data types are check boxes. I need to add how many were checked off. Once I have a count, I will do some error calculation.The value of the column defaults to 0. I have about 20 tables and almost all the columns are bit. I will try the examples given and see if it works. If you have other ideas, please keep them coming. THanks so much! |
 |
|
|
|
|
|