服务器级别的排序规则导致数据库过程中区分大小写的问题

Collation at server level is causing issues with case sensitivity in database procedures

我正在将数据库安装到客户端的服务器上。服务器上设置的排序规则是 SQL_Latin1_General_CP1_CS_AS,因此区分大小写。

我正在安装的数据库使用整理级别SQL_Latin1_General_CP1_CI_AS,因此不区分大小写。

我现在 运行 遇到的问题是存储过程中的所有变量都必须区分大小写,否则会引发错误。

示例:

Declare @Dimension varchar(45)
Set @dimension = 'Test'

错误:

Must declare the scalar variable "@dimension".

@dimension 变量中的小写 "d" 导致它被识别为完全不同的变量。

数据库中是否有我可以更新以忽略服务器排序规则的设置?

注意:我获得了在服务器级别更新排序规则的许可,因为它是测试服务器。然而,这是一个更复杂的过程。我正在寻找一种无需执行此 link:

中找到的步骤即可解决此问题的方法

谢谢

根据经验,更快的方法是备份所有数据库,然后使用正确的排序规则重新安装 sql-服务器,然后恢复所有数据库。可能需要手动操作权限,但可以有其他选项。

要解决此问题,请将您的数据库设置为 Partially Contained. This will give you Contained Database Collation,它提供:

Since a design objective of contained databases is to make them self-contained, the dependence on the instance and tempdb collations must be severed. To do this, contained databases introduce the concept of the catalog collation. The catalog collation is used for system metadata and transient objects.

In a contained database, the catalog collation Latin1_General_100_CI_AS_WS_KS_SC. This collation is the same for all contained databases on all instances of SQL Server and cannot be changed.