好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

自动清理MSSQLServerTableCollation问题的解决方法

在一个团队项目中,没有约定好Collation, 在 MS SQL Server中编程就会遇到这样的问题:
Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

因为编码问题,不同编码的字符串并不能直接进行比较,这种有两个解决方法,1是在 query中 指定 用某一个collation进行比较, 另外一个就是修改column的 collation type 来避免这种错误。

第二种方法,一个一个column改起来很累,写了个script,除了 被当作 constraints比如 primary key, foreign key之外的 varchar, char,nvarchar 都可以统一修改成一个collation…

完整sql代码:

代码如下:

查看更多关于自动清理MSSQLServerTableCollation问题的解决方法的详细内容...

  阅读:39次