当前位置: 代码迷 >> SQL >> 解决mssql中两列的字符编码不一样 相加有关问题
  详细解决方案

解决mssql中两列的字符编码不一样 相加有关问题

热度:31   发布时间:2016-05-05 14:21:29.0
解决mssql中两列的字符编码不一样 相加问题
Result 表中 test_number 的字符编码为:Latin1_General_CI_AS_WS
Name 的字符编码为:Latin1_General_CS_AS_WS
如果直接相加则会出现下面的异常:
select test_number + name from result
Msg 457, Level 16, State 1, Line 2
Implicit conversion of varchar value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict.

解决的办法为:
用下面的sql
select test_number + name collate  Latin1_General_CI_AS_WS from result
  相关解决方案