Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

My technology blog on SQL Server, TSQL, XML, FILESTREAM and other areas of SQL Server.
Browse by Tags · View All
XML 112
TSQL 69
XQuery 69
XQuery Functions 67
XQuery Training 65
XQuery in TSQL 64
XQuery Tutorial 63
SQL Server XQuery 63
XQuery-Labs 57
BRH 38

Archive · View All
September 2008 32
August 2008 30
July 2008 21
August 2009 19
June 2009 19
May 2010 18
January 2009 15
January 2010 14
October 2008 14
June 2008 13

XQuery Lab 11 - How to insert an element to an XML variable

Jul 25 2008 9:43PM by Jacob Sebastian   

 

In the previous post we have seen how to insert an attribute to an XML variable. In this post, let us see how to insert an element to an XML variable. In the example given below, an element named "LastName" is added to the "Employee" element.

DECLARE @x XML
SELECT @x = '
<Employee>
<FirstName>Jacob</FirstName>
</Employee>'


DECLARE @LastName VARCHAR(15)
SELECT @LastName = 'Sebastian'

-- insert an attribute
SET @x.modify('
insert element LastName {sql:variable("@LastName")} as last into
(/Employee)[1]
'
)

-- test the results
SELECT @x

/*
output:
<Employee>
<FirstName>Jacob</FirstName>
<LastName>Sebastian</LastName>
</Employee>
*/

XQuery Labs - A Collection of XQuery Sample Scripts and Tutorials

Tags: XQuery-Labs, XML, XQuery, XQuery Functions, SQL Server XQuery, XQuery in TSQL, XQuery Training, XQuery Tutorial,


Jacob Sebastian
1 · 100% · 32220
1
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"XQuery Lab 11 - How to insert an element to an XML variable" rated 5 out of 5 by 1 readers
XQuery Lab 11 - How to insert an element to an XML variable , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]