SQL Server BCP 实用程序最佳使用分隔符
相信很多人都遇到过这样的场景。
每当我们使用 SQL Server BCP 实用程序向分隔文本文件导入/导出数据时,这是最好使用的“分隔符”
。我们有注释文本类型的字段,其中可以有 ,现在我们发现 | & ~ 也被我们的用户在这些领域使用。 您认为哪个角色被用户使用的机会最少。或者你有更好的选择来处理这个问题。
更新- 该软件正在为英国英语用户开发。
I am sure many would came across this scenario.
Whenever we use SQL Server BCP utility to import/export data to-from delimited text files, which is the best "Separator Character"
to use. We have Note-text kind of fields which can have , and now we found | & ~ is also used by our users in those fields.
Which character in your opinion has least chances of user ever used. Or you have better alternative to deal with this issue.
Update-
This software is being developed in UK-English users.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最好的方法是,您选择用作分隔符的任何字符都不应出现在任何文本字段中,如果您的文本字段包含分隔符,请在将文本放入 bcp 导出文件之前替换它。 ^ 或 |很少使用的字符,因此请使用其中任何一个作为分隔符,并在代码中进行检查,以将文本字段中的分隔符替换为其他字符,这样就不会造成任何混淆。
The best way is to whatever character you select to use as separator should not come in any of your Text field, If your text field contain your separator character then replace it before you place your text into bcp export file. ^ or | are rarely used characters so use anyone of them as separator character and put check in your code to replace your separator character from your text field with some other character so it will not make any confusion.
使用非打印字符 - ASCII 代码 2 和 ASCII 代码 3 通常用作 START 和 STOP 分隔符 (STX/ETX),并且肯定不会出现在用户数据中。
Use non-printing characters - ASCII code 2 and ASCII code 3 are commonly used as START and STOP delimiters (STX/ETX) and are certain not to appear in user data.
答案是,这实际上取决于数据。一个可以使用
^ 或 # 或 ~ 或 |
Answer is that really depends on the data. One could use
^ or # or ~ or |
我更喜欢在 csv 文件中使用两个“奇怪”的字符作为分隔符。我遇到过人们使用
|
和#
插入数据的情况。像^|
或|||
之类的东西应该更好。用BCP来做应该不成问题。
I prefer to use two "weird" characters as separators in my csv files. I've had cases of people inserting data with a
|
and with a#
. Something like^|
or|||
should be better.It shouldn't be a problem doing it with BCP.