SQL Server error “Implicit conversion of because the collation of the value is unresolved due to a collation conflict.”

前端 未结 2 2005
忘了有多久
忘了有多久 2020-12-03 16:50

I getting this error while developing stored procedure

Implicit conversion of varchar value to varchar cannot be performed because the collation of th

相关标签:
2条回答
  • 2020-12-03 17:24

    ALTER TABLE DEPT1 and DEPT2 so that resulting definitions of tables do not contain any COLLATE

    0 讨论(0)
  • 2020-12-03 17:38

    You'd need COLLATE in both places most likely.

    Select City COLLATE DATABASE_DEFAULT AS Place, State, Country FROM DEPT1
    UNION ALL
    Select '' COLLATE DATABASE_DEFAULT AS Place, 'Arizona' As State, Country FROM DEPT2
    

    Edit: You may need it on every string if you get it in one places

    Select
        City COLLATE DATABASE_DEFAULT AS Place,
        State COLLATE DATABASE_DEFAULT AS State,
        Country COLLATE DATABASE_DEFAULT AS Country
    FROM DEPT1
    UNION ALL
    Select
        '' COLLATE DATABASE_DEFAULT,
        'Arizona' COLLATE DATABASE_DEFAULT ,
        Country COLLATE DATABASE_DEFAULT
    FROM DEPT2
    

    Edit2:

    It happens because your column collation is probably different to your database collation. So "City" has one collation but string constants have another.

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