Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I create a table like this

create table char_test(
    item varchar(10) collate SQL_Latin1_General_CP1_CI_AS

I can store varchars containing

insert into char_test values ('≥');

When I do a

select item from  char_test;

I get


But using

select replace(item, '≥', '>=') from  char_test;



So the database knows the character. How can I convert the string to a nvarchar showing this character?


The important fact here is, that SQL Server here maps some different characters to the same character without throwing errors or warnings.

I dare call this very bad design.

share|improve this question
up vote 5 down vote accepted

varchar doesn't support : unicode only

This includes the literal '≥' which is varchar too

Collation here doesn't matter: this is sorting and comparison only never seen this before!

Some more SQL to use your table

SELECT ASCII('≥'), CHAR(61), '≥'
insert into char_test values ('≥');
select item, ASCII(item) from  char_test;
select replace(item, '≥', '>='), replace(item, '=', '>=') from  char_test;

create table nchar_test(
    item varchar(10) collate SQL_Latin1_General_CP1_CI_AS,
    Nitem nvarchar(10) collate SQL_Latin1_General_CP1_CI_AS
insert into nchar_test values ('≥', N'≥');
select item, ASCII(item), Nitem, UNICODE(Nitem) from nchar_test;

Edit: after more playing

If you have a value then use CP 437

select CAST(Nitem COLLATE SQL_Latin1_General_CP437_CI_AS AS varchar) from nchar_test;
select CAST(N'≥' COLLATE SQL_Latin1_General_CP437_CI_AS AS varchar)

Note: the ASCII is 242 but this won't give either :-)

   ASCII(CAST(N'≥' COLLATE SQL_Latin1_General_CP437_CI_AS AS varchar)),
   CHAR(242) COLLATE SQL_Latin1_General_CP437_CI_AS

You may be able to control this with database collation but frankly use unicode...

share|improve this answer was the N before the '≥' I was missing, good catch. – SQLRockstar Apr 13 '11 at 14:35

If I run this:

select UNICODE ( '≥' )
select UNICODE ( '=' )
select UNICODE ( item ) from  char_test;

They all return the same number, 61. I don't think the REPLACE proves that the character is being recognized. I even changed the char_test table to have the item column defined as nvarchar(10) and it still doesn't recognize the '≥'.

My best guess here is that you need a different collation, or to insert the data using a different method than SSMS (assuming you did the same as I did).


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.