如何从 SQL Server 表中导出文本数据?

发布于 2024-07-29 04:47:12 字数 145 浏览 4 评论 0原文

我正在尝试使用 MS SQL Server 2005 导入/导出工具导出表,以便我可以将其导入到另一个数据库中进行存档。 其中一列是文本,因此如果我导出为逗号分隔,当我尝试将其导入存档表时,对于该字段中带有逗号的行,它无法正常工作。 我应该选择哪些选项来确保导入正常进行?

I am trying to use the MS SQL Server 2005 Import/Export tool to export a table so I can import it into another database for archival. One of the columns is text so if I export as comma-delimited, when I try to import it into the archive table, it doesn't work correctly for rows with commas in that field. What options should I choose to ensure my import will work correctly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

無處可尋 2024-08-05 04:47:12

一年多后,我现在有了一个满足数据导出需求的理想解决方案,这要归功于 https://stackoverflow.com/questions/20363/

bcp "SELECT * FROM CustomerTable" queryout "c:\temp\CustomerTable.bcp" -N -S SOURCESERVERNAME -T 

bcp TargetDatabaseTable in "c:\temp\CustomerTable.bcp" -N -S TARGETSERVERNAME -T -E
  • -N 使用本机类型
  • -T 使用可信连接
  • -S ServerName
  • -E 保留数据文件中指定的标识值可以

非常快速且轻松地嵌入到代码中。

Over a year later, I now have an ideal solution to my data export needs, thanks to https://stackoverflow.com/questions/20363/

bcp "SELECT * FROM CustomerTable" queryout "c:\temp\CustomerTable.bcp" -N -S SOURCESERVERNAME -T 

bcp TargetDatabaseTable in "c:\temp\CustomerTable.bcp" -N -S TARGETSERVERNAME -T -E
  • -N use native types
  • -T use the trusted connection
  • -S ServerName
  • -E Keep identity values specified in the data file

Very quick and easy to embed within code.

他不在意 2024-08-05 04:47:12

除非客户需要,否则我从不使用逗号分隔符。 尝试使用 | 作为分隔符。 如果需要,您还可以使用文本限定符。

I never use the comma delimter unless the client requires it. Try using | as a delimter. YOu can also use the text qualifier if need be.

未蓝澄海的烟 2024-08-05 04:47:12

使用引号作为文本限定符

文本限定符:
输入要使用的文本限定符。 例如,您可以指定每个文本列都用引号引起来。

Use quotes as text qualifier

Text qualifier:
Type the text qualifier to use. For example, you can specify that each text column be surrounded with quotation marks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文