MS SQL Server bit column exported as boolean
Asked Answered
E

2

6

I'm trying to export data from SQL Server to flat files.

The data includes a bit column 0/1 and I need it as is but it get exported as Boolean TRUE/FALSE which is causing ETL bulk insert to fail.

enter image description here

I tried changing the data mapping to single byte integer, float, numeric, string, text hoping to get a simple 0/1 but nothing worked.

Any pointers on how to solve this are appreciated (other than replacing text within the resulted file).

Ensconce answered 16/12, 2018 at 23:58 Comment(3)
Is this relevant dwbi1.wordpress.com/2011/11/16/…Trela
Perhaps a case statement on export to cast as INT?Ecphonesis
@scsimon I'm using the export wizard there's no option to add a case statement. Or is there another way to export?Ensconce
G
2

Add a IIF in your select to convert Boolean to 0/1 to export:

SELECT Name, Code
    ,IIF(EuroZone = 1, 1, 0) AS EuroZone
    ,IIF(Visible= 1, 1, 0) AS Visible
FROM your_table
Gillian answered 12/8, 2020 at 4:50 Comment(0)
I
0

The problem is, SQL Server has a bit data type. It does not have a boolean, while SSIS uses .Net data types, not SQL data types. It supports boolean, not bit. Though it has built-in conversions, to resolve problems like that. So in my opinion, you need to use a derived column to solve that.

Infirmary answered 17/12, 2018 at 3:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.