The following bcp command is auto converting empty strings to nulls:
BCP "stored_proc_name" queryout C:\Outdir\data.csv -c -t , -T -Sserverx -Uusery -Ppassz -dproddb
I need the empty strings to be retained and not be replaced by NULLs.
What's the best way to do this? Can the bcp auto conversion be turned off?
The best way is to leave null value not empty string on database. Then BCP will export empty string into file (.csv, .txt or so).
Please refer to BCP MSDN:
- out copies from the database table or view to a file. If you specify an existing file, the file is overwritten. When extracting data, note that the bcp utility represents an empty string as a null and a null string as an empty string.