declare @sql varchar(8000)
declare @xml as xml
declare @xml_convert varchar(max)
set @xml=(select ProductID, Name from SalesLT.Product
FOR XML AUTO, ELEMENTS XSINIL, type)
set @xml_convert='<?xml version="1.0" encoding="UTF-8"?>'+cast(@xml as varchar(max));
IF OBJECT_ID('tempdb..##x') IS NOT NULL DROP TABLE ##x;
select @xml_convert AS x into ##x;
set @sql='bcp "SELECT x FROM ##x" queryout C:\ -S '+@@servername+' -T -w -t -C1255;'
EXEC master..xp_cmdshell @sql
drop table ##x
for exporting an xml file with utf-8 encoding i use the above code
unfortunately the receiver can't import it
because the file include binary data
what is wrong with my code?
thanks ahead