Professional Web Applications Themes

When I compare two string in Unicode format. - Microsoft SQL / MS SQL Server

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)+nchar(49352)+nchar(47811)+nchar(48256 )+nchar(4966)+nchar(25 736)+nchar(1788)+nchar(51220)+nchar(17733) Set str2 = nchar(21121)+nchar(49352)+nchar(47811)+nchar(48256 )+nchar(4966)+nchar(25 736)+nchar(1788)+nchar(51220)+nchar(17733)+nchar(4 1273) 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 *** ...

  1. #1

    Default 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)+nchar(49352)+nchar(47811)+nchar(48256 )+nchar(4966)+nchar(25
    736)+nchar(1788)+nchar(51220)+nchar(17733)

    Set str2 =
    nchar(21121)+nchar(49352)+nchar(47811)+nchar(48256 )+nchar(4966)+nchar(25
    736)+nchar(1788)+nchar(51220)+nchar(17733)+nchar(4 1273)



    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!
    Laurent Guest

  2. #2

    Default Re: When I compare two string in Unicode format.

    DIFFERENCE makes compares the SOUNDEX values of two strings. The SOUNDEX
    algorithm is designed to work with English words in the Latin alphabet, and
    it doesn't work properly with other languages and definitely not other
    alphabets. You can see that the SOUNDEX value for both the strings is 0000,
    so even if you turn them around and compare them they will still be the same
    (see code at the end).

    For a brief overview of how SOUNDEX works, see this link:
    http://www.archives.gov/research_room/genealogy/census/soundex.html


    Set str =
    nchar(21121)+nchar(49352)+nchar(47811)+nchar(48256 )+nchar(4966)+nchar(25736)
    +nchar(1788)+nchar(51220)+nchar(17733)

    Set str2 =
    nchar(25736)+nchar(1788)+nchar(51220)+nchar(17733) +nchar(21121)+nchar(49352)
    +nchar(47811)+nchar(48256)+nchar(4966)+nchar(41273 )

    select str
    select str2

    SELECT DIFFERENCE(str, str2)
    SELECT soundex(str)
    SELECT soundex(str2)

    --
    Jacco Schalkwijk MCDBA, MCSD, MCSE
    Database Administrator
    Eurostop Ltd.


    "Laurent Liegeois" <be> wrote in message
    news:phx.gbl... 


    Jacco Guest

  3. #3

    Default RE: When I compare two string in Unicode format.

    Looks like the same message was posted three times? See reply to the one
    posted Wed, 30 Jul 2003 02:54:54 -0700 in
    microsoft.public.sqlserver.programming.



    --------------------
    From: Laurent Liegeois <be>
    X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
    Subject: When I compare two string in Unicode format.
    Mime-Version: 1.0
    Content-Type: text/plain; cht="us-ascii"
    Content-Transfer-Encoding: 7bit
    Message-ID: <phx.gbl>
    Newsgroups: microsoft.public.sqlserver.programming
    Date: Wed, 30 Jul 2003 02:54:55 -0700
    NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
    Lines: 1
    Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
    Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.programming:377645
    X-Tomcat-NG: microsoft.public.sqlserver.programming


    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)+nchar(49352)+nchar(47811)+nchar(48256 )+nchar(4966)+nchar(25
    736)+nchar(1788)+nchar(51220)+nchar(17733)

    Set str2 =
    nchar(21121)+nchar(49352)+nchar(47811)+nchar(48256 )+nchar(4966)+nchar(25
    736)+nchar(1788)+nchar(51220)+nchar(17733)+nchar(4 1273)



    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!


    Bart Guest

Similar Threads

  1. Compare string with XML
    By Emil RT in forum Macromedia Flash Data Integration
    Replies: 1
    Last Post: July 4th, 10:39 AM
  2. Problem compare string with array
    By John in forum PERL Beginners
    Replies: 4
    Last Post: May 14th, 08:57 PM
  3. What are the advantages of .ai file format compare to eps?
    By elenaPechatnikov@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 1
    Last Post: May 1st, 01:10 AM
  4. Unicode String Becomes Distorted In ASP
    By JJY in forum ASP Components
    Replies: 0
    Last Post: October 8th, 11:21 PM
  5. Compare string case sensitive
    By Miroo_news in forum Microsoft SQL / MS SQL Server
    Replies: 8
    Last Post: July 17th, 11:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139