Cannot resolve the collation conflict between “SQL_AltDiction_CP850_CI_AS” and “SQL_Latin1_General_CP1_CI_AS” in the equal to operation

前端 未结 2 1252
广开言路
广开言路 2021-01-24 07:46

I have a piece of code in my stored procedure as below -

update tblexpwitretrocmdocs set sCheckedOut = A.sEditor, idone = 0 
from #tblDocs A
JOIN tblexpwitretroc         


        
相关标签:
2条回答
  • 2021-01-24 08:03

    Specify DATABASE_DEFAULT for the collation of all temp table string columns to use the current database default collation:

    CREATE TABLE #tblDocs(
        iId INT IDENTITY (1,1),
        SID NVARCHAR(50) COLLATE DATABASE_DEFAULT,
        iDocumentTypeId INT,
        sType NVARCHAR(200) COLLATE DATABASE_DEFAULT,
        sEditor NVARCHAR(50) COLLATE DATABASE_DEFAULT
    );
    

    For columns that differ from the database default collation, specify the exact column collation instead of DATABASE_DEFAULT.

    0 讨论(0)
  • 2021-01-24 08:18

    To resolve the collation conflict add "COLLATE DATABASE_DEFAULT" keywords around “=” operator as shown below:

    UPDATE tblexpwitretrocmdocs SET sCheckedOut = A.sEditor, idone = 0 
    FROM #tblDocs A
    JOIN tblexpwitretrocmdocs B ON A.SID = B.SID
    WHERE A.iDocumentTypeId in (16,17,13,11) COLLATE DATABASE_DEFAULT
    AND A.sid COLLATE DATABASE_DEFAULT NOT IN 
    (SELECT SID COLLATE DATABASE_DEFAULT FROM tblexpwitdocumentgeneral)
    

    Hope this helps...

    0 讨论(0)
提交回复
热议问题