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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combine xml data types 1

Status
Not open for further replies.

iwease

IS-IT--Management
Sep 4, 2006
104
CA
Hi,

I'm having difficulty finding out how to do the following in sql server 2005. I want to take two xml variables @a and @b, and combine them such that @c = @a + @b (so that @b would just appear after @a).

I would also like to be able to say something like @a = '<xx>' + @a + '</xx><yy>' + @b + '</yy>'

I know I can do this by first CASTing the xml datatype to a varchar, calling CONCAT, and then CASTing back to xml....but i am worried that this may truncate some of the xml data since VARCHAR has a limited length
 
Use VARCHAR(MAX) instead of VARCHAR. The XML datatype is based on the NVARCHAR(MAX) datatype and has the same 1 billion byte limit.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top