让bcp.exe转义终止符 [英] Getting bcp.exe to escape terminators

查看:207
本文介绍了让bcp.exe转义终止符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用SQL Server 2000的BCP实用程序导出一些数据。有时我的数据包含字符,例如\t和\\\
,我需要用作列和行终结符。如何让BCP将它用作终端符的字符转换为输出数据,以便实际上可以在另一个程序中导入数据?

I need to export some data using SQL Server 2000's BCP utility. Sometimes my data contains characters, such as \t and \n, that I need to use as column and row terminators. How do I get BCP to escape characters it's using as terminators as it outputs the data, so that I can actually import the data in another program?

例如,我的列是文本数据,并包含选项卡和换行符。 BCP只是按原样导出它,我试图将它们导入的程序会被困惑,因为数据在行中间和/或行中包含额外的列,没有明显的原因。

For example, one of my columns is text data, and includes tabs and newlines. BCP just exports them as-is, and the program I'm trying to import them with gets confused because the data ends in the middle of a line and/or a line contains extra columns for no apparent reason.

这似乎是一个非常非常非常的基本功能,可以包含在数据导出器中,但没有一个命令行选项似乎提到它。 (为什么不是默认值超出我的范围。)我错过了什么?

This seems like a very, very, very basic function to include in a data exporter, but none of the command-line options seem to mention it. (Why it wouldn't just be the default is beyond me.) Am I missing something?

推荐答案

你不能包含标签和换行符的数据,带有选项卡和换行符分隔符。这个不成立。转义不会有帮助,因为标签是标签。我们不是在这里说c#字符串处理。

You can't have data containing tabs and newlines with tabs and newline separators. It makes no sense. Escaping wouldn't help, because a tab is a tab. We're not talking c# string handling here.

我要做的是使用不同的终结者,例如 | || / n ,或使用格式文件

What I'd do is use different terminators such as | and ||/n, or use a format file

这篇关于让bcp.exe转义终止符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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