Skip to Content
avatar image
Former Member

How to add encoding line to SQL Query?

Hi. I need to export XML files from SAP BUSINESS ONE. I builded XML structure successfully but i am having a hard time to add the encoding line on the top of the SQL result. I would like to have some help. Thanks alot. Ron.

/*SELECT FROM [dbo].[OINV] T0*/ 


declare @docnumasint/* where */set@docnum='11702773'     
DECLARE @Header TABLE(DOCNUM VARCHAR(100),cardcode NVARCHAR(30));
DECLARE @Detail TABLE(U_Line_NumD NVARCHAR(3),dscription NVARCHAR(300),ITEMCODE VARCHAR(30));


INSERT INTO @Header
SELECT  t0.docnum , t0.cardcode


from OINV t0 
where t0.docnum =@docnum


INSERT INTO @Detail 
SELECT  U_Line_NumD,t1.dscription,t1.ITEMCODE
FROM INV1 t1  inner join oinv t0 on t0.docentry = t1.docentry


where t0.docnum =@docnum
DECLARE @XML XML =(
SELECT *
FROM @Detail AS dd
FOR XML PATH('Line'),ROOT('Lines'),TYPE
);


SELECT(
    SELECT *    
    FROM  @Header AS hd
    FOR XML PATH('HeaderRow'),ROOT('Header'),TYPE
  ),(@XML)
FOR XML PATH ('Root')
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers