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 56 – Inserting elements with UNICODE values

Jun 9 2010 6:02AM by Jacob Sebastian   

I think it will be quite common that you try to insert a UNICODE value into an XML document and then you see that the INSERT did not work correctly because the value you find within the XML document is slightly different from what you inserted. I got a similar question recently and thought of adding it to the XQuery labs as it might help other people with similar problems.

The following example shows the problem.

DECLARE @xml XML
SELECT @xml = '<root></root>'
	
SET @xml.modify('insert element a {"Szövlő"} as last into (/root)[1]')
SELECT @xml
/*
<root>
  <a>Szövlo</a>
</root>
*/

Note that the value we entered was “Szövlő”. However, the XML output shows “Szövlo” (note the missing accent mark on o). This can be fixed by changing your query to a UNICODE string, as given in the following example.

DECLARE @xml XML
SELECT @xml = '<root></root>'
	
SET @xml.modify(N'insert element a {"Szövlő"} as last into (/root)[1]')
SELECT @xml
/*
<root>
  <a>Szövlő</a>
</root>
*/

Here is another version of the query that uses a variable instead of a hard-coded value.

DECLARE @xml XML, @val NVARCHAR(20)

SELECT 
	@xml = '<root></root>',
	@val = N'Szövlő'
	
SET @xml.modify('insert element a {sql:variable("@val")} into (/root)[1]')
SELECT @xml
/*
<root>
  <a>Szövlő</a>
</root>
*/

View All Labs: XQuery Labs - A Collection of XQuery Sample Scripts and Tutorials

Visit the XML Resource Center for more XML articles and tutorials.

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


Jacob Sebastian
1 · 100% · 32004
1
 
0
Lifesaver
 
0
Refreshed
 
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"XQuery Lab 56 – Inserting elements with UNICODE values" rated 5 out of 5 by 1 readers
XQuery Lab 56 – Inserting elements with UNICODE values , 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]