When I compare two string in Unicode format.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Laurent Liegeois

    When I compare two string in Unicode format.

    Hi,
    I have a funny Error in our sql server 7 & 2000. When I compare two
    string in Unicode format. I receive that it is the same when I add new
    nchar.
    I don’t understand why?


    Could you help me ?

    declare @str nvarchar(128), @str2 nvarchar(128)



    Set @str =
    nchar(21121)+nc har(49352)+ncha r(47811)+nchar( 48256)+nchar(49 66)+nchar(25
    736)+nchar(1788 )+nchar(51220)+ nchar(17733)

    Set @str2 =
    nchar(21121)+nc har(49352)+ncha r(47811)+nchar( 48256)+nchar(49 66)+nchar(25
    736)+nchar(1788 )+nchar(51220)+ nchar(17733)+nc har(41273)



    select @str

    select @str2

    SELECT DIFFERENCE(@str , @str2)



    if soundex(@str) = soundex(@str2)

    BEGIN

    SELECT 'OK'

    END

    ELSE

    BEGIN

    SELECT 'KO'

    END

    if @str = @str2

    BEGIN

    SELECT 'OK'

    END

    ELSE

    BEGIN

    SELECT 'KO'

    END


    -=zoltux=-

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Erland Sommarskog

    #2
    Re: When I compare two string in Unicode format.

    [posted and mailed, please reply in news]

    Laurent Liegeois (zoltix@skynet. be) writes:[color=blue]
    > I have a funny Error in our sql server 7 & 2000. When I compare
    > two string in Unicode format. I receive that it is the same when I add
    > new nchar. I don’t understand why?
    >
    > Could you help me ?
    >
    > declare @str nvarchar(128), @str2 nvarchar(128)
    >
    > Set @str =
    > nchar(21121)+nc har(49352)+ncha r(47811)+nchar( 48256)+nchar(49 66)+
    > nchar(25736)+nc har(1788)+nchar (51220)+nchar(1 7733)
    >
    > Set @str2 =
    > nchar(21121)+nc har(49352)+ncha r(47811)+nchar( 48256)+nchar(49 66)+
    > nchar(25736)+nc har(1788)+nchar (51220)+nchar(1 7733)+nchar(412 73)[/color]

    When I use the Character Map in Windows (Under Accessories/System Tools),
    I cannot find any character defined at U+A139 (=41273). I would suppose
    that a trailing undefined character counts as blank, which explains why
    @str1 = @str2 are equal.



    --
    Erland Sommarskog, SQL Server MVP, sommar@algonet. se

    Books Online for SQL Server SP3 at
    SQL Server 2025 redefines what's possible for enterprise data. With developer-first features and integration with analytics and AI models, SQL Server 2025 accelerates AI innovation using the data you already have.

    Comment

    Working...