Search code examples
sqlsql-serverbcp

SQL Server BCP Empty File


I'm trying to use bcp to query out a comma-separated-value file but each time I get an empty file.

Here's my bcp command:

bcp "SELECT * FROM ##OutAK "  QUERYOUT D:\Outbound\raw\li14090413.raw -c -T -t -S DB1

I have verified that ##OutAK is NOT empty because select count (*) from ##OutAK is not 0. When open file using HEX editor, I see the following:

0D 0A

Solution

  • I found the problem. It seems BCP is "allergic" with NULL. So, I just put ISNULL() to all the null-able fields and the output file is back to normal now.