Home All Groups Group Topic Archive Search About
Author
24 Nov 2005 2:20 PM
Hege M
Hallo!

I wondered if anyone can help me with why there is a N' in front of so many
of the expressions in create statements?  Like this one.
CREATE XML SCHEMA COLLECTION DeliverySchemas
AS
N'<?xml version="1.0" ?>

Thanks!
H

Author
24 Nov 2005 2:26 PM
Tibor Karaszi
It is the way you express a Unicode string.

Show quote
"Hege M" <He***@discussions.microsoft.com> wrote in message
news:9FA0AC1B-AF43-4A41-BB3D-D731B6D6D148@microsoft.com...
> Hallo!
>
> I wondered if anyone can help me with why there is a N' in front of so many
> of the expressions in create statements?  Like this one.
> CREATE XML SCHEMA COLLECTION DeliverySchemas
> AS
> N'<?xml version="1.0" ?>
>
> Thanks!
> H
>
Author
25 Nov 2005 2:38 PM
Kent Tegels
Hello Hege,

> I wondered if anyone can help me with why there is a N' in front of so
> many
> of the expressions in create statements?  Like this one.
> CREATE XML SCHEMA COLLECTION DeliverySchemas
> AS
> N'<?xml version="1.0" ?>

Justing adding a bit of depth to Tibor's answer. For SQL Server 2005, the
schema's textual presentation must matching its actual encoding. When SQL
Server 2005 attempts to parse and store XML, it looks at two things:

1. From a T-SQL prespective, was the literal text value presented as single-byte-per-character
text (essentially ASCII) or as double-byte-per-character text. In SQL Server,
prefixing an 'N' (note that capitial N is required) tells T-SQL to treat
what follows as a double-byte string.

Note that this behavior is true for databases setup in the an English configuration,
where textual values are assumed to single-byte by default. This behavior
may vary for versions of SQL Server localized to double-byte languages. I've
never installed SQL in Japanesse, for example, to see what the actual behavior
is.

2. As XMLRW begins parsing the XML, it looks at the prologue for an encoding
attribute (e.g., encoding="utf-8", encoding="utf-16", etc). If this fails
to immediately match the expected byte-per-character-count from #1, an error
is raised. Otherwise, processing continues.

Thank you,
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/

AddThis Social Bookmark Button