使用 BCP 从 SQL Server 表写入文件

发布于 2024-08-06 00:40:49 字数 321 浏览 1 评论 0原文

我刚刚意识到我在 SQL Server 中的工作已经结束了,哈哈。

无论如何,我尝试使用 bcp

serverName.databaseName.databaseInstanceName.TableName

写入

C:\FileName.xml

并且我只想写入列 Col1Col2,我可以获得一些语法帮助吗?我在这里挣扎。

谢谢,

特德

I just realized my caps was on from working in SQL Server, ha.

Anyways, Im trying to write from

serverName.databaseName.databaseInstanceName.TableName

to

C:\FileName.xml

using bcp and I want to write only columns Col1 and Col2, could I get a little syntax help? I'm struggling over here.

Thanks,

Ted

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

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

发布评论

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

评论(2

迷迭香的记忆 2024-08-13 00:40:49

为了创建 XML 版本的格式文件,除了使用 -x 参数之外,命令是相同的。

bcp "SELECT col1, col2 FROM AdventureWorks.HumanResources.Department" format nul -c -x -f department.xml -T -S servername

In order to create an XML version of the format file the command is identical except we use the -x parameter.

bcp "SELECT col1, col2 FROM AdventureWorks.HumanResources.Department" format nul -c -x -f department.xml -T -S servername
不及他 2024-08-13 00:40:49

仅供其他人参考...

bcp“从 dbInstanceName.dbo.tableName 选择任何内容” quesryout C:\output.txt -e C:\errors.txt -c -T -S localhost\dbName

FYI for anyone else....

bcp "Select whatever from dbInstanceName.dbo.tableName" quesryout C:\output.txt -e C:\errors.txt -c -T -S localhost\dbName

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