Click to See Complete Forum and Search --> : VB6 and Sql Server/Express - Boolean to Bit !!


hbkelkar
October 21st, 2006, 04:58 AM
hi gurus,
I'm writing my applications in vb6 and was using Access as backend. Now i've migrated from access to Sql Server / Express 2005. Here im facing a problem.
My program used a table where there is a boolean(True/False) field. When i converted (from import utility in Sql Server) access database to Sql server, True/False field is handled as Bit (0/1).

My code in vb6 already contained ways to handle the fields as boolean fields.
e.g. "Select table.field1, table.field2 where table2.field2 = " & false

When all boolean columns are bits in Sql, i've to rewrite the above statements all over.

Is there any way to convert/cast the bit(0/1) fields to work as (yes/no)..

Any idea to accomplish this task...

WarlockSoul
October 24th, 2006, 09:30 AM
Hi,

Have you tried the Case Statement in SQL to convert you bits into Yes/No?

You could do some like the following:

Declare @bitTest [Bit]

Set @bitTest = 1

Select
Case
When @bitTest = 1 Then N'Yes'
Else N'No'
End as 'Test'