January 27, 2017 at 1:25 am
for inserting the XML Declaration
i use the next code:
set @xml=(select xml_data from Xmltable)
set @xml_convert='<?xml version="1.0" encoding="UTF-8"?>'+cast(@xml as nvarchar(max));
IF OBJECT_ID('tempdb..##x') IS NOT NULL DROP TABLE ##x;
select @xml_convert AS x into ##x;
bcp "select * from table'" queryout C:\filename.dat -S @@servername -t -c -C 65001 -T
EXEC master..xp_cmdshell @sql
but the XML Declaration dose not appear in the xml file.
glad for any help
January 27, 2017 at 1:30 am
sam-433147 - Friday, January 27, 2017 1:25 AMfor inserting the XML Declaration
i use the next code:set @xml=(select xml_data from Xmltable)
set @xml_convert='<?xml version="1.0" encoding="UTF-8"?>'+cast(@xml as nvarchar(max));
IF OBJECT_ID('tempdb..##x') IS NOT NULL DROP TABLE ##x;select @xml_convert AS x into ##x;
bcp "select * from table'" queryout C:\filename.dat -S @@servername -t -c -C 65001 -T
EXEC master..xp_cmdshell @sqlbut the XML Declaration dose not appear in the xml file.
glad for any help
You will have to add it in the bcp query, once in the XML type column, it is stripped off.
😎
Question, how are you making certain that the output is UTF-8? If it isn't, this whole exercise does not make sense.
January 27, 2017 at 3:42 am
Eirikur Eiriksson - Friday, January 27, 2017 1:30 AMsam-433147 - Friday, January 27, 2017 1:25 AMfor inserting the XML Declaration
i use the next code:set @xml=(select xml_data from Xmltable)
set @xml_convert='<?xml version="1.0" encoding="UTF-8"?>'+cast(@xml as nvarchar(max));
IF OBJECT_ID('tempdb..##x') IS NOT NULL DROP TABLE ##x;select @xml_convert AS x into ##x;
bcp "select * from table'" queryout C:\filename.dat -S @@servername -t -c -C 65001 -T
EXEC master..xp_cmdshell @sqlbut the XML Declaration dose not appear in the xml file.
glad for any help
You will have to add it in the bcp query, once in the XML type column, it is stripped off.
😎Question, how are you making certain that the output is UTF-8? If it isn't, this whole exercise does not make sense.
thank's for the replay
-C 65001 in the bcp string make's it as utf-8
the file is UTF-8 encoding without a doubt
can you show me how to add it in the bcp query?
thanks ahead
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply