SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Remove root from a xml file


Remove root from a xml file

Author
Message
mcdbaexpert
mcdbaexpert
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 19
I have created a table, created a stored procedure to retrieve data into xml(I used 'for xml path'),
created a package in sql 2005 BIDs, created a execute sql task and a script task. I was able to produce the xml file from SSIS. The output is shown below.

<ROOT>
- <row>
<Module>C</Module>
<AccountRef>1759</AccountRef>
<BenefitSuppressionIndicator>BP</BenefitSuppressionIndicator>
<RecoveryInhibitIndicator>RI</RecoveryInhibitIndicator>
</row>
- <row>
<Module>C</Module>
<AccountRef>2734</AccountRef>
<BenefitSuppressionIndicator>BP</BenefitSuppressionIndicator>
<RecoveryInhibitIndicator>RI</RecoveryInhibitIndicator>
</row>
- <row>
<Module>C</Module>
<AccountRef>3859</AccountRef>
<BenefitSuppressionIndicator>BP</BenefitSuppressionIndicator>
<RecoveryInhibitIndicator>RI</RecoveryInhibitIndicator>
</row>
- <row>
<Module>C</Module>
<AccountRef>40000666</AccountRef>
<BenefitSuppressionIndicator>BP</BenefitSuppressionIndicator>
<RecoveryInhibitIndicator>RI</RecoveryInhibitIndicator>
</row>
</ROOT>

My question is that how can make change </ROOT> to be </xml> as shown below?

<xml>
- <row>
<Module>C</Module>
<AccountRef>1759</AccountRef>
<BenefitSuppressionIndicator>BP</BenefitSuppressionIndicator>
<RecoveryInhibitIndicator>RI</RecoveryInhibitIndicator>
</row>
- <row>
<Module>C</Module>
<AccountRef>2734</AccountRef>
<BenefitSuppressionIndicator>BP</BenefitSuppressionIndicator>
<RecoveryInhibitIndicator>RI</RecoveryInhibitIndicator>
</row>
- <row>
<Module>C</Module>
<AccountRef>3859</AccountRef>
<BenefitSuppressionIndicator>BP</BenefitSuppressionIndicator>
<RecoveryInhibitIndicator>RI</RecoveryInhibitIndicator>
</row>
- <row>
<Module>C</Module>
<AccountRef>40000666</AccountRef>
<BenefitSuppressionIndicator>BP</BenefitSuppressionIndicator>
<RecoveryInhibitIndicator>RI</RecoveryInhibitIndicator>
</row>
</Xml>
stevefromOZ
stevefromOZ
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: Moderators
Points: 3546 Visits: 3757
Did you look up the syntax for FOR XML - it's right there - option to change the root name. http://msdn.microsoft.com/en-us/library/ms190922(v=sql.90).aspx

Steve.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search