在SQL Server中使用BCP命令导出xml数据 [英] Export xml data using BCP Command in SQL Server

查看:92
本文介绍了在SQL Server中使用BCP命令导出xml数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以xml格式导出datable数据,但是问题就像我能够创建xml文件一样,但是数据无法写入该文件,这是我正在尝试的代码.

I am trying to export datable data in xml format but,Problem is like i can able to create xml file but data is not get writing in to the file following is my code I am trying.

DECLARE @cmd  VARCHAR(2000);

SET @cmd = 'bcp.exe "select * from emp FOR XML AUTO" queryout E:\rahul_1.xml -x -T';

EXEC xp_cmdshell  @cmd ;

以下是执行上述代码后得到的输出消息

And following is the output message I am getting after executing above code

NULL
Enter the file storage type of field XML_F52E2B61-18A1-11d1-B105-00805F49916B [ntext]: 

任何人都可以在这个问题上建议我

can any body please suggest me on this

推荐答案

除了最后一件事情,您的答案还可以. BCP需要有关源查询的其他信息.完全限定数据源的最佳方法.

Dan you answer works, except one last thing. BCP needs additional information about the source query. Best idea to fully qualify the source of the data.

SET @cmd = 'bcp.exe "select * from [Database].[Schema].[Table] FOR XML AUTO" 
             queryout E:\rahul_1.xml -c -T';

这篇关于在SQL Server中使用BCP命令导出xml数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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