Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 N prefix and collation

Author  Topic 

schalling
Starting Member

1 Post

Posted - 2008-02-05 : 09:26:12
I have the following statement:

declare @a1 nvarchar(300)
set @a1 = 'Strona_glówna'

declare @a2 nvarchar(300)
set @a2 = N'Strona_glówna'

select *
from Table
where [Row] like @a1

If I run the select statement with the @a1 no results are displayed yet if I run it with @a2 I get results (the correct ones).

The table row is nvarchar(300)

Should @a1 not be unicode when declared nvarchar ??

- if not then how do I change a parameter @par (passed to a stored procedure) to its equivelent unicode @par? I mean if I recieve @par as a parameter and want to make sure it is unicode (as if made with the prefix N) ?

(Im running MSSql Server 2005 obviously)

Hope you can help me.

/Schalling

Ifor
Aged Yak Warrior

700 Posts

Posted - 2008-02-05 : 10:34:46
This assigns an ASCII constant to an unicode string.
(ie 'Strona_glówna' is converted to char(13) and then to nvarchar(300))

declare @a1 nvarchar(300)
set @a1 = 'Strona_glówna'

This assigns an unicode constant to an unicode string. (The N on the front of the string makes it unicode.)

declare @a2 nvarchar(300)
set @a2 = N'Strona_glówna'
Go to Top of Page
   

- Advertisement -