如何编写非默认排序规则的脚本并跳过默认排序规则的显式脚本? [英] How to script non-default collation and skip explicit scripting for default collation?

查看:77
本文介绍了如何编写非默认排序规则的脚本并跳过默认排序规则的显式脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SSMS 2008 R2中,我创建了一个表:

In SSMS 2008 R2, I created a table:

aTest(Albnian varchar(10), Dflt varchar(10))

在SSMS表设计器中,两列均具有以下排序规则:< database default> (在列属性→表设计器下)

In SSMS table designer, both columns have the collation: "<database default>" (under "Column Properties" → "Table Designer")

我将 Albnian列的排序规则更改为非默认值,例如Albanian_CI_AS。

I changed the collation of the column "Albnian" to a non-default, for example, Albanian_CI_AS.

如果我在SSMS中编写表格脚本(右键单击 aTest→脚本表格为→创建至→新建查询编辑器窗口,则得到[1

If I script the table in SSMS (right click on "aTest" → "Script Tables as" → "CREATE To" → "New Query Editor Window", I get [1] with no explicit collations scripted at all.

Bad。

很显然,人们希望表格是

Obviously, one would expect the table to be scripted with explicit collation for non-default collation (the one that the developer intentionally introduced with a specific purpose) and no collation for default collation.

在SSMS菜单中→工具→在非默认排序规则中使用显式排序规则编写脚本,以用于非默认排序规则(开发人员有针对性地出于特定目的而故意引入的排序规则)。选项→SQL Server对象资源管理器→脚本,我进行了更改:

In SSMS menu → Tools → Options → SQL Server Object Explorer → Scripting, I changed:


  • 包括排序规则:True

  • 脚本默认值:False

但是现在,我正在编写所有列排序规则的脚本,包括默认和非默认排序规则[2]。

but now, I am getting all column collations scripted, both default and non-default ones [2].

如何配置脚本生成脚本非默认排序规则,并跳过默认排序规则,例如[3]?

How can I configure script generation to script non-default collation and skip the default ones, as in [3]?

[1]表的默认脚本:

[1] Default scripting of table:

CREATE TABLE [dbo].[aTest]
(
    [Albnian] [varchar](10) NOT NULL,
    [Dflt] [varchar](10)  NOT NULL
) ON [PRIMARY]

[2]表包含排序规则之后的脚本更改为True

[2] Table script after "Include collation" changed to True

CREATE TABLE [dbo].[aTest]
(
    [Albnian] [varchar](10) COLLATE Albanian_CI_AS NOT NULL,
    [Dflt] [varchar](10) COLLATE Cyrillic_General_CI_AS NOT NULL 
) ON [PRIMARY]

[3]所需的整理脚本生成行为:

[3] Needed collation script generation behavior:

CREATE TABLE [dbo].[aTest]
(
    [Albnian] [varchar](10) COLLATE Albanian_CI_AS NOT NULL,
    --non-default should be scripted

    [Dflt] [varchar](10) NOT NULL 
    -- default database collation should not be scripted
) ON [PRIMARY]

相关问题:

  • What issues to anticipate having different collations between development and production SQL Servers?

推荐答案

我通过MS Connect提交了建议:

对所有列或不为所有列编写了排序规则

I submitted a suggestion through MS Connect:
Collations are scripted either for all columns or for none

以下是相关的答复:


Microsoft 发布> 2010年11月11日上午10:16

根纳季:

Posted by Microsoft on 11/11/2010 at 10:16 AM
Hi Gennady:

感谢您写信给Microsoft。我们非常重视您的反馈。我们了解您的问题,以及解决此问题如何提高生产率的方法。

Thanks for writing in to Microsoft. We greatly value your feedback. We understand your problem, and how fixing this could improve productivity.

但是,考虑到实施这项工作将涉及的工作以及我们的可交付成果,我们认为,我们将无法在不远的将来。

However, given the work that would be involved in implementing this work, and our set of deliverables, we do not think, we would be able to get to this in the near future.

话虽如此,我们很重视您的建议,并向您保证,将来我们再次访问此功能时,我们会牢记这些想法。

Having said that, we value your suggestions, and would like to assure you that, we would keep these ideas in mind, when we do revisit this feature in the future.

再次感谢您提供反馈并使SQL Server成为最出色的数据库服务器。

Thanks again for providing feedback and making SQL Server the greatest Database server.

致谢

钱德拉穆里

这篇关于如何编写非默认排序规则的脚本并跳过默认排序规则的显式脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆