问题描述
我有一个存储过程,生成具有FOR XML
功能的XML.运行存储过程时,结果得到了格式精美的XML.
I have a stored procedure generating XML with FOR XML
functionality. When I run the stored procedure, I get beautifully formatted XML as a result.
当我尝试使用bcp将结果导出到文件中
When I try to export this result into a file with bcp
declare @sql varchar(8000)
select @sql = 'bcp "exec sp_ExportXml" queryout C:\Filename.xml -S (local) -T -w'
exec master..xp_cmdshell @sql
我在xml标记内的换行格式很差,例如
I get a badly formatted with line breaks inside the xml tags e.g.
<Division>3</Divi
sion>
我完全一无所知,我为bcp queryout
尝试了几种不同的参数,但总是得到相同的结果.
I am completely clueless, I tried several different parameters for bcp queryout
but always getting the same result.
任何想法都受到高度赞赏!谢谢
Any ideas are highly appreciated! Thanks
推荐答案
我可以通过不使用bcp来解决此问题,而是按照下面的建议在SqlCommand上运行ExecuteXmlReader: http://support.microsoft.com/kb/310378
I could solve this by not using bcp but instead run ExecuteXmlReader on the SqlCommand as suggested here: http://support.microsoft.com/kb/310378
这篇关于SQL Server Bcp导出XML格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!