Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding xml tags using sql

Status
Not open for further replies.

sds814

Programmer
Feb 18, 2008
164
US
I have a sql query that is producing a xml tree from the sql tables. Now I need to append an xml tag to the xml tree.

Is there an easy way to do that?

The way that I found out through googling is to convert the xml tree to a string and concatenante the strings together (xml tree with the new xml tag that I need to add). The problem with that is that when I cast the xml tree as nvarchar(max) the xml is getting truncated as noted in this post (
I'm hoping SQL 2005 has an easier way to append xml tags.
 
What I'm trying to do seems simpler.

I'm trying to add '<?xml version="1.0" encoding="utf-8"?>'
to the results of this:
Code:
SELECT TOP 10 LOAN_ID
FROM TMSMTG AS LOAN
WHERE EFF_DT = '12/31/2010'
FOR XML AUTO, TYPE, ROOT('LoanData')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top