Collation Sequence and Table Variables

  • I have two databases on the same instance (SQL2000) on the same server with the same collation sequence. However, when I update a table in one from a table variable created within a stored procedure in the other, it falls over with 'Cannot resolve collation conflict for equal to operation'.

    Specifying an explicit collation sequence for the join fixes the problem.

    I note that the server has a different collation sequence to the databases (I am not allowed to change it because of impacts elsewhere). I speculate that table variables (and temporary tables?) take the collation sequence of the server and not of the database in which they are created. Can anybody confirm?

  • Stewart,

    I believe that the table variable will, by default, use the collation from TEMPDB.

    You should be able to fix this by defining the collation within the creation of the table variable:

    declare @mytable table (somecol varchar(200) collate database_default)

    --
    Adam Machanic
    whoisactive

  • I can confirm that TempDB has got the 'wrong' collation sequence so your explanation fits. Thanks for your response.

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

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