Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 For XML Explicit

Author  Topic 

ftsoft
Starting Member

22 Posts

Posted - 2010-07-15 : 19:53:38
Hello

I have a SP which builds an XML string below:

It creates the XML string

<E18><E18_03>0</E18_03><E18_08>4390</E18_08></E18><E18><E18_03>0</E18_03><E18_08>4390</E18_08></E18><E18/><E18/>

The datbase table looks like:

pk_E18 fk_E01 E18_03 E1808
2036 1016 0 4390
2037 1016 0 4390

I'm not sure why the <E18/>'s appear at the end, but I would like to get rid of them.

Thanks for your help.

ALTER PROCEDURE [dbo].[RunXMLE18]
(
@RunID varchar(10)
)

AS
/* SET NOCOUNT ON */


SELECT 1 as Tag,
NULL as Parent,
E18_03 as [E18!1!E18_03!Element],
E18_08 as [E18!1!E18_08!Element]

FROM E01 INNER JOIN E18 ON
E01.pk_E01 = E18.fk_E01
WHERE E01.E01_01 = @RunID AND E18_03 IS NOT NULL




UNION ALL

SELECT
1 as tag,
NULL as parent,
NULL,
NULL

FROM E01 INNER JOIN E18 ON
E01.pk_E01 = E18.fk_E01
WHERE E01.E01_01 = @RunID AND E18_03 IS NOT NULL

FOR XML EXPLICIT



RETURN


Frank

Sachin.Nand

2937 Posts

Posted - 2010-07-16 : 00:56:21
There are no root nodes for your XML.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

ftsoft
Starting Member

22 Posts

Posted - 2010-07-16 : 07:44:38
I'm not sure what you mean? This is just a fragment of the entire xml which is created by several SP's. I have to admit that the FOR XML Explicit syntax is not my strong point.

Frank
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-07-16 : 08:49:51
You need to post the entire XML.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2010-07-16 : 12:34:40
is this related to following?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=135107&SearchTerms=FOR
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=138024&SearchTerms=FOR

If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -