How do I transform byte to bits using SSIS?

267 views Asked by At

I'm using SSIS to import several fields from a DB2 database on an IBM I-series. The fields are 1 character (1 byte) and each of the 8 bits represents a different flag, so 00000001 might mean the account is new, 10000000 might mean that a statement was dropped today, and 10000001 would mean that both flags are 'On'. The fields are already imported into SQL char(1) from a flat file generated from the I-Series. I do have access to the flat files if necessary.

Casting to varbinary returns 0x20 when none of the bits are on when I would expect zero.

I tried a script task:

        flags = Row.lnflg4.ToCharArray()[0];
        bits = Convert.ToString(flags, 2).PadLeft(8, '0');

How can I get the binary value so I can split that into 8 separate bit fields in SQL Server? Or get the binary, then convert that to decimal so I could use 1 as the 'New Account value' and 128 as the statement value with 129 as both? Or something else?

0

There are 0 answers