bcp.exe输出中的不可打印字符 [英] Unprintable characters in bcp.exe output

查看:105
本文介绍了bcp.exe输出中的不可打印字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要使用批处理作业转储三个MSSQL Server表.我四处搜索,发现强烈建议将bcp用于此类工作.查看文档,似乎我想要的是转储整个表,因为我需要所有数据,而不是子集.

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>

带有-n或-n和-C的各种组合,并且虚假的,不可打印的字符出现在.csv文件中,例如带有变音符号或倒置的y,镜像反转为"L".还有实际数据以及这些字符,它们似乎出现在每一列的末尾.

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.

从SQL Server表中提取干净的.csv数据的最佳方法是什么,以便可以从批处理作业中运行它?

What is the best way to extract clean .csv data from a SQL Server table, so it can be run from a batch job?

推荐答案

数据可能已经干净:使用-n获得的本机格式是

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.

如果您希望脚本与其他工具一起使用,请按照文档 a>,最好使用字符格式,即如果没有Unicode数据,则为-c,如果没有,则为-w.

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.

这篇关于bcp.exe输出中的不可打印字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆