Query returns incorrect results.

  • Hello,

    I get incorrect number of records from the following two temp tables below. Can you please help me understand why it behaves this way and the possible resolutions?

    CREATE TABLE #TEMP (name varchar(80))

    INSERT INTO #TEMP values ('Malteser Schloßschule')

    INSERT INTO #TEMP values ('Malteser Schlossschule')

    CREATE TABLE #TEMP1 (name nvarchar(160))

    INSERT INTO #TEMP1 values ('Malteser Schloßschule')

    INSERT INTO #TEMP1 values ('Malteser Schlossschule')

    SELECT * FROM #TEMP WHERE name ='Malteser Schlossschule'

    -- Results :- 'Malteser Schlossschule'

    Query 2:

    SELECT * FROM #TEMP1 WHERE name ='Malteser Schlossschule'

    -- Results :- Malteser Schloßschule

    -- Malteser Schlossschule

    The collation of tempdb is SQL_Latin1_General_CP1_CI_AS. I'm using SQL Server 2005.

    Thanks!

  • Hi nihcas77,

    Use COLLATE Latin1_General_CS_AS

    ---

  • The values inserted aren't the same. You're using a code that's different fo the first "s" in the #temp table, so it's not equal to 'Malteser Schlossschule'. the cast to VARCHAR still keeps this is a different character.

    The Unicode result must be handling things differently with the collation.

Viewing 3 posts - 1 through 2 (of 2 total)

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