what am i doing wrong -- char(240)

  • what I am doing wrong, why the result is '=' ?

    declare @C table ( c1 varchar(10) )
    insert into @C select '≡'

    select * from @C

  • goher2000 - Tuesday, January 16, 2018 1:40 PM

    what I am doing wrong, why the result is '=' ?

    declare @C table ( c1 varchar(10) )
    insert into @C select '≡'

    select * from @C

    Try this:

    declare @C table ( c1 nvarchar(10) )

    insert into @C select N'≡'

    select * from @C

  • goher2000 - Tuesday, January 16, 2018 1:40 PM

    what I am doing wrong, why the result is '=' ?

    declare @C table ( c1 varchar(10) )
    insert into @C select '≡'

    select * from @C

    You need to add some N's to handle unicode characters.

    declare @C table ( c1 NVARCHAR(10) )
    insert into @C select N'≡'

    select * from @C

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • it didn't work, probably something to do with collation, I am on SQL_Latin1_General_CP1_CI_AS

    print CONVERT(VARCHAR(3), ASCII('=')) + ' = ' + CHAR(240)

    print CONVERT(VARCHAR(3), ASCII(N'=')) + ' = ' + CHAR(240)

  • goher2000 - Tuesday, January 16, 2018 2:03 PM

    it didn't work, probably something to do with collation, I am on SQL_Latin1_General_CP1_CI_AS

    print CONVERT(VARCHAR(3), ASCII('≡')) + ' = ' + CHAR(240)

    print CONVERT(VARCHAR(3), ASCII(N'≡')) + ' = ' + CHAR(240)

    Try

    print nchar(0x2261)

  • goher2000 - Tuesday, January 16, 2018 2:03 PM

    it didn't work, probably something to do with collation, I am on SQL_Latin1_General_CP1_CI_AS

    print CONVERT(VARCHAR(3), ASCII('≡')) + ' = ' + CHAR(240)

    print CONVERT(VARCHAR(3), ASCII(N'≡')) + ' = ' + CHAR(240)

    You need to use N'≡' instead of '≡'.  You need to use UNICODE() instead of ASCII.  You need to use NVARCHAR(4) instead of VARCHAR(3).

    SELECT CONVERT(NVARCHAR(5), UNICODE(N'≡')) + ' = ' + CHAR(240)

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • thanks guys

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply