Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL bit type field resulting in 0, -1 instead of 0, 1

I have a table in a SQL db with a bit field. When I select distinct values in SQL management studio, I get 0 and 1, but in QlikView I get 0 and -1. Is there some special way I'm supposed to handle bit types? Thanks!

3 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Sounds similar to boolean fields... QlikView treats boolean "true" as -1.

If you are consistently getting -1, then just reverse the sign during load.

biester
Specialist
Specialist

I agree with Oleg that sign should be reversed (or by using an absolute value be omitted), but would use (assuming that the name of the bit field is BitField):

fabs(BitField Xor 0)

Thus, if you expect only 0 or 1, you only GET 0 or 1 (even if BitField is not consistently read as -1).

But that's perhaps mere of theoretical interest ..

Rgds,
Joachim

Anonymous
Not applicable
Author

Hi, I am new to QlikView, and had the same unexpected experience using BIT values from SQL Server.

A work-around I used was to change the SQL load script and convert data type to INT, e.g.

,cast( t.IsActive as INT) as IsActive

Hope this helps.

Regards

Terry