Msg 468, Level 16, State 9, Procedure "procedurename", Line 129 Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

  • Dear All,

    I have a stored procedure and I keep getting the following error message:

    Msg 468, Level 16, State 9, Procedure "procedurename", Line 129

    Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

    I looked at the Collation for the Database and it is SQL_Latin1_General_CP1_CI_AS but I don't know what else I need to do to get it working please?

    Thank you in advance!

  • Could be anything from situation where joining tables have different collation for the columns they are joined on, to using temp tables in the proc and having different default collation in tempdb

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • tt-615680 (4/12/2012)


    Dear All,

    I have a stored procedure and I keep getting the following error message:

    Msg 468, Level 16, State 9, Procedure "procedurename", Line 129

    Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

    I looked at the Collation for the Database and it is SQL_Latin1_General_CP1_CI_AS but I don't know what else I need to do to get it working please?

    Thank you in advance!

    Have you looked at line 129 in the procedure to see what is happening in the procedure at that point? We can't tell from here, our crystal balls don't seem to work.

    From what you have posted there is a collation difference between two values (or columns). One is using Latin1_General_CI_AS and the other SQL_Latin1_General_CP1_CI_AS.

  • Thank you for your reply!

    This is part of the stored procedure:

    ........................

    ...................

    CREATE TABLE Data

    (

    Total_TY decimal(10,2), --this is where is gives the error

    Total_LY decimal(10,2),

    variance decimal(10,2)

    )

    INSERT INTO #Data

    SELECT

    CASE WHEN ISNULL(ISNULL(Total_TY,0)/ISNULL(Total_LY,1), 0) = ISNULL(Total_TY, 0) THEN 100

    WHEN ISNULL(ISNULL(Total_LY,0)/ISNULL(Total_TY,1), 0) = ISNULL(Total_LY, 0) THEN -100

    ELSE ISNULL((ISNULL(Total_TY,0)/ISNULL(Total_LY,1)), 0) END AS var

    FROM#TYear c

    LEFTJOIN #LYear pON c.countryCode = p.countryCode

    What I'm confused about is that when I run the same stored procedure on a different Server it runs fine and the setting for the Collation are the same.

    Thank you!

  • I would look at the two temporary tables #TYear and #LYear and how they are created. Most specifically the countryCode columns.

  • tt-615680 (4/12/2012)


    Thank you for your reply!

    This is part of the stored procedure:

    ........................

    ...................

    CREATE TABLE Data

    (

    Total_TY decimal(10,2), --this is where is gives the error

    Total_LY decimal(10,2),

    variance decimal(10,2)

    )

    INSERT INTO #Data

    SELECT

    CASE WHEN ISNULL(ISNULL(Total_TY,0)/ISNULL(Total_LY,1), 0) = ISNULL(Total_TY, 0) THEN 100

    WHEN ISNULL(ISNULL(Total_LY,0)/ISNULL(Total_TY,1), 0) = ISNULL(Total_LY, 0) THEN -100

    ELSE ISNULL((ISNULL(Total_TY,0)/ISNULL(Total_LY,1)), 0) END AS var

    FROM#TYear c

    LEFTJOIN #LYear pON c.countryCode = p.countryCode

    What I'm confused about is that when I run the same stored procedure on a different Server it runs fine and the setting for the Collation are the same.

    Thank you!

    What is the collation of your SQL Server instance, Tempdb objects will use the server collation and that's undoubtedly where your issue is. Post the results from the following run against your SQL instance

    select serverproperty('collation')

    select databasepropertyex('tempdb', 'collation')

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Thank you for all your advice!

    I used COLLATE DATABASE_DEFAULT and it worked:

    Table1.Column1 COLLATE DATABASE_DEFAULT = Table2.Column1 COLLATE DATABASE_DEFAULT

    Thank you everyone for you advice!

  • Dear SSC Veteran,

    Thanks A Lot.

    Dinesh

  • Thank you SSC Veteran!

  • Hi guys,

    I'm have same issue:

    Msg 468, Level 16, State 9, Procedure RPT_MTX_CDR_CostBreakdown_PerMsisdn, Line 142

    Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.

    I have the query below and my error massage is pointing at Line 142 and Line 142 is the SELECT DISTINCT.Please assist.

    Select distinct ---------line 142

    aa.Msisdn,

    bb.box_no

    into #MSISDNUnit

    from #AllMSISDNCost aa

    left join [10.24.4.56\EGHI].wasp_administration_SS.dbo.z_Unit_Lookup bb

    on aa.MSISDN COLLATE DATABASE_DEFAULT = bb.MSISDN COLLATE DATABASE_DEFAULT

    where bb.msisdn in (Select distinct msisdn from #AllMSISDNCost)

    order by bb.box_no--24202

  • GOODS (9/19/2013)


    Hi guys,

    I'm have same issue:

    Msg 468, Level 16, State 9, Procedure RPT_MTX_CDR_CostBreakdown_PerMsisdn, Line 142

    Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.

    I have the query below and my error massage is pointing at Line 142 and Line 142 is the SELECT DISTINCT.Please assist.

    Select distinct ---------line 142

    aa.Msisdn,

    bb.box_no

    into #MSISDNUnit

    from #AllMSISDNCost aa

    left join [10.24.4.56\EGHI].wasp_administration_SS.dbo.z_Unit_Lookup bb

    on aa.MSISDN COLLATE DATABASE_DEFAULT = bb.MSISDN COLLATE DATABASE_DEFAULT

    where bb.msisdn in (Select distinct msisdn from #AllMSISDNCost)

    order by bb.box_no--24202

    If you need to force the collation on the ON condition you also need to enforce it on the WHERE condition, as the columns involved are the same; so you could make it bb.MSISDN COLLATE DATABASE_DEFAULT in (Select distinct msisdn COLLATE DATABASE_DEFAULT from #AllMSISDNCost) .

    Are you running with ANSI NULLs switched off, so that NULL in (select NULL) would deliver true?

    Or are you working in a case sensitive system so that one (or both) of #AllMSISDNCost and z_Unit_Lookup has two columns, one called MSISDN and the other msisdn?

    If neither of the above rather unusual things is true, do you think that filtering the result of left join on the equality condition by applying that where clause will produce something which would not be achieved by simplifying of the query to use an inner join and throwing away the where clause?

    Tom

  • Thanks it worked..

  • Hello,

    I am looking for the resolution/clue for the error message I have been receiving since last 2-3 days.

    Here is the scenario:

    I have an .NET application where I am using SQL Server 2012 with Advanced Services x86 for database management. My development PCs have Windows 7 OS (one with 32-bit and other with 64-bit). The application is running as expected. I added one more PC with Windows 8 OS (64-bit) for testing purpose. I installed SQL Server 2012 with Advanced Services x64 on that PC. When I restored the database from Win7 pc to Win8 pc it got restored successfully in one go. On the database side, on both Win7 and Win8 pc, the database collation is set to the default type "SQL_Latin1_General_CP1_CI_AS"

    Since past 2-3 days the application, when run on the Win8 pc, is giving me error for a particular stored procedure Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation. It happens only on Win8 pc. I have not used any collation directives while using joins or comparing column values. I have already rechecked and reset the collation type on both the PCs but the error still persists on the win8 pc.

    I am wondering why is this happening only on Win8 pc?

    Could this issue be related with SQL Server version on Win8 pc? If yes, what could be the resolution to the issue?

    Please share your valuable thoughts.

    Thanks in advance.

  • Amod Pusalkar (12/20/2014)


    Hello,

    I am looking for the resolution/clue for the error message I have been receiving since last 2-3 days.

    Here is the scenario:

    .....

    On the database side, on both Win7 and Win8 pc, the database collation is set to the default type "SQL_Latin1_General_CP1_CI_AS"

    It's a very long time since any release of MS SQL Server has had that default. The default has been Latin1_General_CI_AS for at least 6 years, and I believe for quite a bit longer. Obvioulsy if you are working with MS SQL Server 2012 you must have set the instance default to SQL_Latin1_General_CP1_CI_AS on installation of one or more of your systems, and left it at the default on one or more.

    The solution is first to find out what each instances default collation is. Then change the default collation of whatever instances can be changed with least trouble. You may also have to change column collations explicitly for any tables created with a column or columns using the instance default collation. If you are lucky the database schema designers will have explicitly declared collations for all character type columns so that that won't be necessary (you could still get errors with temp tables and maybe with sql local variables, so ).

    Sometimes the easiest way to change the default collation for an instance is to uninstall it and reinstall with the correct default collation, but you need to be very careful that you don't lose any data if you do it that way. The alternative is the Rebuild Master utlity (if it still exists - I haven't used in recent versions of SQL Server) but some people find that harder than the other way even when they have lots of data to preserve.

    Tom

  • TomThomson (12/20/2014)


    It's a very long time since any release of MS SQL Server has had that default. The default has been Latin1_General_CI_AS for at least 6 years, and I believe for quite a bit longer. Obvioulsy if you are working with MS SQL Server 2012 you must have set the instance default to SQL_Latin1_General_CP1_CI_AS on installation of one or more of your systems, and left it at the default on one or more.

    The solution is first to find out what each instances default collation is. Then change the default collation of whatever instances can be changed with least trouble. You may also have to change column collations explicitly for any tables created with a column or columns using the instance default collation. If you are lucky the database schema designers will have explicitly declared collations for all character type columns so that that won't be necessary (you could still get errors with temp tables and maybe with sql local variables, so ).

    Sometimes the easiest way to change the default collation for an instance is to uninstall it and reinstall with the correct default collation, but you need to be very careful that you don't lose any data if you do it that way. The alternative is the Rebuild Master utlity (if it still exists - I haven't used in recent versions of SQL Server) but some people find that harder than the other way even when they have lots of data to preserve.

    Hello Mr Tom,

    Thanks for your quick reply.

    While performing the installation of SQL Server 2012 Express on all afore-mentioned PCs I had kept the Collation type to whatever pre-filled value. I believe that value was "SQL_Latin1_General_CP1_CI_AS" so I thought it to be default for SQL Server. Also, I have checked the collation for model and tempdb databases and found that it was also "SQL_Latin1_General_CP1_CI_AS". There is no explicit collation specification for any column in any table hence it is "SQL_Latin1_General_CP1_CI_AS" for each column. If I am correct then the collation for database is preserved during the backup & restore activity and therefore on the destination server (if different than source) the server level collation and DB level collation can be different (I stand to be corrected by experienced members).

    So in the mean while I am going to recheck all collation settings on each SQL instance once again.

    --

    Amod Pusalkar

Viewing 15 posts - 1 through 14 (of 14 total)

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