Collation issue

  • Hello,

    I have a database which I have restored from a SQL 2005 server which is of the following server collation type:

    SQL_Latin1_General_CP1_CI_AS

    The SQL 2005 server I have restored to has the following server collation type:

    Latin1_General_CI_AS

    However, the database I restored has the same database collation type on both servers, which is:

    SQL_Latin1_General_CP1_CI_AS

    The database has a stored proc which uses 'FOR XML EXPLICIT' to construct and return an XML result set . When I try to run this stored proc, I get the following error:

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

    Does anyone have any ideas why this is happening? Could this indicate I need to change the collation on the server I am restoring to?

    If I do have to change the collation of the server, can somebody please explain why this is the case (I would have thought the database collation being the same would be sufficient). Also, is it possible to detach all databases, then rebuild master using the new collation type, then reattached the databases? Or would all databases have to be removed and then restored?

    Thanks very much in advance!

  • The reason for this issue is that when you restore a database to another server it keeps it original collation. Now then stored procedures or other processes make use of the tempdb to store data in variables or temporary objects the collation of the tempdb is different from the one in the database.

    You're options to avoid this issue are either using the COLLATE funtion to explicitly convert string values or changing the collation on your database/tables using ALTER.

    Changing the server collation is possible, but first of all you should think about that this will have impact on all databases on the server and which collation is the one you really want.

    Also changeing the server collation is basically a new installtion of your master database and you have to reapply service packs afterwards.

    http://msdn.microsoft.com/en-us/library/ms179254(SQL.90).aspx

    Hope this helps

    [font="Verdana"]Markus Bohse[/font]

  • You could try checking your SP for #temp tables and table variables. If you are using these then adding COLLATE DATABASE_DEFAULT to the definitions of string columns may solved your problem.

  • Yeah that's what I thought. It's going to be much easier to rebuild my master DB as it's just a test server at this point. There will be too many SPs to unecessarily change if I leave it as is.

    Thank you very much for your help!

  • In fact, I like rebuildm utility of SQL Server 2000 which save time & very quick instead of Setup.exe in SQL Server 2005.

    ---------------------------------------------------
    "Thare are only 10 types of people in the world:
    Those who understand binary, and those who don't."

Viewing 5 posts - 1 through 4 (of 4 total)

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