使用不同的 SQL Server 2008 排序规则进行测试

发布于 2024-12-12 10:59:31 字数 471 浏览 2 评论 0原文

目前我正在创建一个 T-SQL 脚本来验证某个数据库中的数据。此脚本正在验证大量 NVARCHAR 列以检测数据问题。

由于此脚本必须在 1000 多个数据库上运行,因此我遇到了不同服务器和附加数据库的排序规则设置问题。

在生产环境中的计算机上运行脚本之前,我无法更改开发电脑上的数据库和服务器的排序规则来测试这一点。

  • 服务器和数据库排序规则无法更改,是否正确?
  • 是否有更改服务器或数据库排序规则的解决方法?

如果这是可能的或者有另一种测试方法,它将节省我测试我创建的庞大脚本的时间。

编辑:我不清楚目标:
我需要使查询中的排序规则相等。我可以通过在生产环境中的所有计算机上运行脚本来完成此操作。如果查询出现问题,我可以找到错误并添加 COLLATION 子句。我想在我的开发计算机上测试这一点,而不是在客户环境上开始测试这部分脚本。

Currently I am creating a T-SQL script to verify data in a certain database. This script is validating a lot of NVARCHAR columns to detect data problems.

Because this script must be run on more than 1000 databases, I encountered problems with collation setting of the different servers and attached databases.

I was not able to change the collation of my database and server on my development pc to test this before run the script on the machines in the production environment.

  • Is it correct the server and database collation cannot be changed?
  • Is there a workaround to change server or database collation?

If this is possible or there is another way to test, it will save me time to test the huge script I have created.

EDIT: I was not clear about the goal:
I need to make the collations equal in the query. I can do this by running the script on all machines in the production environment. If the query causes problems, I can go to the error and add the COLLATION clause. I want to test this on my development machine instead of start testing this part of the script on a customers environment.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暮色兮凉城 2024-12-19 10:59:31

为了安全起见,我会使用 COLLATE 子句在查询中显式地使排序规则相等。

http://msdn.microsoft.com/en-us/library/ms184391.aspx

For safety I would explicitly make collations equal in the queries using COLLATE clause.

http://msdn.microsoft.com/en-us/library/ms184391.aspx

〆一缕阳光ご 2024-12-19 10:59:31

当然您可以更改这些:

但请注意:更改排序规则(服务器或数据库)不会更改数据库中已存在的列的排序规则!

如果您需要执行此操作,则需要更改所有数据库的每个表中的每个相关列。

Sure you can change those:

But be aware: changing a collation (both server or database) does not change the collation on the columns that are already present in your database!

If you need to do this, you need to change every relevant column, in every table of all your databases.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文