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
 General SQL Server Forums
 New to SQL Server Programming
 Problem with N Prefix?

Author  Topic 

Prog01
Starting Member

3 Posts

Posted - 2011-11-09 : 00:07:47
select case when 'A-12' > N'A112TA' then 1 else 0 end return 1
select case when 'A-12' > 'A112TA' then 1 else 0 end return 0

But
select case when 'A112TA' = N'A112TA' then 1 else 0 end return 1

I don't know why?
I tested in SQL 2000 and SQL 2005.

Pls Help.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-09 : 00:57:30
why whats the problem? they're equal isnt it? so it will return 1 only

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Prog01
Starting Member

3 Posts

Posted - 2011-11-09 : 01:06:55
Thank you for quick response.
In this case:
'A-12' > N'A112TA', 'A-12' < 'A112TA' but N'A112TA' = 'A112TA' and 'A-12' = N'A-12'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-09 : 01:08:53
sorry i didnt get what you're trying to ask here. its the expected behaviour isnt it? what else you're expecting?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Prog01
Starting Member

3 Posts

Posted - 2011-11-09 : 01:16:12
'A-12' < 'A112TA' but when i insert N so 'A-12' > N'A112TA'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-09 : 01:30:59
N means it will regard it as unicode. thats why the sequence changes as codepage used for unicode is different from default codepage


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -