I'm going to export DB2 data to CSV file and want to use it with bcp command to import to SQL Server
I have a problem with empty string migration.In bcp, an empty character is a control code of 0x00, so when exporting on the DB2 side I'm trying to output a file with empty characters as 0x00:
export to /tmp/output5.csv of DEL MODIFIED BY NOCHARDEL
select
CASE WHEN COL2 = '' THEN BINARY('',1) ELSE COL2 END AS COL2,
CASE WHEN COL3 = '' THEN BINARY('',1) ELSE COL3 END AS COL3
from TBL1
;
I got SQL Error:
SQL0581N The data types of the result-expressions of a CASE expression or DECODE function are not compatible. SQLSTATE=42804
How to output a control code to a file when the data is an empty string?
1条答案
按热度按时间smdnsysy1#
Using x'00' instead of BINARY('',1) seems to work fine.