cancel
Showing results for 
Search instead for 
Did you mean: 

Bit is converted to 'true' and 'false'

fmdf
New Contributor III

Everytime I pull data from SQL Server / Salesforce etc, if the data type is bit, it returns a string of ‘true’ or ‘false’ that I am then having to convert back to a 0 or 1.

How do I get this to behave differently?

4 REPLIES 4

winosky
New Contributor III

Hi @fmdf, depending on the destination if it’s another db usually it could take care of it without the conversion but if it’s to excel then I would try using an execute snap and converting it within the execute snap or if that’s not an option maybe look into the match data type option in the select snap maybe.

fmdf
New Contributor III

It chokes because the source is bit and the destination is bit. It is converting bit to string and then when it tries to insert into the target, it fails.

I have it working with a mapper but it seems like they should stop converting bit to string.

image001.png

image001.jpg

bojanvelevski
Valued Contributor

Hi @fmdf ,

I can think of two solutions:

  1. You can cast the value while reading in your query => SELECT CAST(field AS int)
  2. Use a Mapper with a ternary operator within SnapLogic => $field == ‘true’ ? 1 : 0

Regards,
Bojan

fmdf
New Contributor III

Thank you for the suggestions.

I am doing the mapper solution now.

Why should I have to cast a field as int when it is already a bit and therefore not string?

I don’t really want to do either of these options but it seems I have no choice.

I just want them to stop converting my bit data to a string. If they can’t handle bit, at least automate it to int instead of a string.

It creates extra work for me with the “no code” solution (rolling eyes).

image001.png

image001.jpg