Добрий день.
Допоможіть, будь ласка, з запитом
drop table if exists ##TempTable;
create table ##TempTable (xmlfield nvarchar(max))
insert into ##TempTable
(xmlfield)
select cast((
SELECT tblProductsNEW.LOCALCODE, tblProductsNEW.FULLNAME, tblBrands.BRANDEXTID,
tblProductsNEW.BRANDNAME, tblSubBrands.SUBBRANDEXTID, tblProductsNEW.SUBBRANDNAME,
tblProductsNEW.PACK_QTY, tblCategorys.CATEGORYEXTID, tblProductsNEW.CATEGORYNAME,
tblSubCategorys.SUBCATEGORYEXTID, tblProductsNEW.SUBCATEGORYNAME
FROM tblProductsNEW INNER JOIN
tblBrands ON tblProductsNEW.BRANDNAME = tblBrands.BRANDNAME INNER JOIN
tblCategorys ON tblProductsNEW.CATEGORYNAME = tblCategorys.CATEGORYNAME INNER JOIN
tblSubBrands ON tblProductsNEW.SUBBRANDNAME = tblSubBrands.SUBBRANDNAME INNER JOIN
tblSubCategorys ON tblProductsNEW.SUBCATEGORYNAME = tblSubCategorys.SUBCATEGORYNAME
for xml raw('LocalProduct'), type, root('LocalProducts')) as nvarchar(max))
update ##TempTable set
xmlfield = '' + xmlfield + ''
declare @cmdshell nvarchar(4000) = 'bcp "select * from ##TempTable" queryout "E:\Sales_dep\FTP\EFFIE\Out\LocalProducts.xml" -T -c -w -r -t -S "N_NSWIT_SQL\MSSQL2017" -d "PPB_Central"';
EXEC xp_cmdshell @cmdshell
Видає
<?xml version="1.0"?>-
-
Треба додати кодування, щоб було
<?xml version="1.0" encoding="UTF-8"?>-
-
Дякую.