问题
I want is to dump three MSSQL Server tables using a batch job. I searched around and found bcp is highly recommended for this kind of work. Looking at the documentation, it seemed what I wanted was to dump the entire table, because I wanted all the data, not a subset.
I am using the following command to extract data from the first table.
bcp glmaster out d:\ftp_root\data_xfer\glmaster.txt -n -d mu_live -t"," -S munis -U <user> -P <pwd>
with various combinations of -n or -n and -C, and spurious, unprintable characters appear in the .csv file, like a y with an umlaut or an upside down, mirror reversed "L". There is also actual data along with these characters, which appear to be at the end of each column.
What is the best way to extract clean .csv data from a SQL Server table, so it can be run from a batch job?
回答1:
The data may already be clean: the native format you get with -n
is a binary format intended for bcp.exe only so it's not surprising that some characters are unreadable.
If you want a script to use with other tools then per the documentation, character format would be a better choice, i.e. -c
if you have no Unicode data, or -w
if you do.
来源:https://stackoverflow.com/questions/13934017/unprintable-characters-in-bcp-exe-output