本文介绍了bcp queryout xml格式文件编码utf-8 xml文件验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须以"encoding ="UTF-8"的格式生成xml文件.我使用bcp queryout.正在生成xml文件.但是我的问题是xml文件验证失败.有人可以帮助我解决此问题吗?是我的代码.
I have to generate xml file for the format of encoding="UTF-8. I used bcp queryout. xml file was generating. But my issue was the xml file validation fail. could any one help me to resolve this? This is my code.
DECLARE @xmlBody AS VARCHAR(MAX)= '<?xml version="1.0" encoding="UTF-8"?>'+ CAST(@xmlStr AS VARCHAR(MAX))
INSERT INTO [dbo].[MasterXml]
([PurchaseOrderID] ,[Code])
values (@PurchaseOrderID, @xmlBody)
Declare @command varchar(8000)
SET @command= 'bcp "SELECT TOP 1 [Code] from [tec_Dev].[dbo].[MasterXml] where PurchaseOrderID='+
CAST( @PurchaseOrderID As varchar(20))+'" queryout '
+@uploadFolder + CAST(@PurchaseOrderID AS varchar(20))+'.xml' +' -T -N -w -c -C65001'
print @command
EXEC xp_cmdshell @command
推荐答案
我找到了解决方法
+@uploadFolder + CAST(@PurchaseOrderID AS varchar(20))+'.xml' +' -T -N -w -c -C65001'
我从代码中删除了-w.然后就可以了.但这仅适用于Microsoft SQL Server 2014(SP2-CU6)(KB4019094)-12.0.5553.0(X64).
I remove the -w from the code. then it works. But it works only forMicrosoft SQL Server 2014 (SP2-CU6) (KB4019094) - 12.0.5553.0 (X64).
这篇关于bcp queryout xml格式文件编码utf-8 xml文件验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!