如何修改SQL Server 中数据库的Collation


下面是EntLib.com Team 针对本地数据库subtext --- 修改Collation 的操作过程。

默认情况下,Subtext 数据库的collation 并不是 Chinese_PRC_CI_AS ,下面通过SCRIPT 脚本修改其collation:
ALTER DATABASE SubtextData COLLATE Chinese_PRC_CI_AS

但是,你会遇到如下错误信息:
Msg 5075, Level 16, State 1, Line 1
The object 'iter_charlist_to_table' is dependent on database collation. The database collation cannot be changed if a schema-bound object depends on it. Remove the dependencies on the database collation and then retry the operation.
Msg 5072, Level 16, State 1, Line 1
ALTER DATABASE failed. The default collation of database 'SubtextData' cannot be set to Chinese_PRC_CI_AS.

这是因为修改数据库的collation时,必须满足如下条件:

  • No one else can be using the database.
  • No schema-bound object can be dependent on the database collation. Schema-bound objects include any of the following:
    • User-defined functions and views created with SCHEMABINDING
    • Computed columns
    • CHECK constraints
    • Table-valued functions that return tables with character columns with collations inherited from the default database collation 
       

上述错误提示信息表示存在数据库对象'iter_charlist_to_table'  依赖于数据库的collation,因此无法成功修改数据库subtext的collation。
 
下面进一步查询上述的'iter_charlist_to_table' 对象具体信息:
select * from sys.objects where name='iter_charlist_to_table'

发现 'iter_charlist_to_table'  是一个 Table-valued Function。需要先导出该function 的SQL script脚本,然后删除该function。

这样,ALTER DATABASE SubtextData COLLATE Chinese_PRC_CI_AS  就可以成功执行了。

最后,执行 'iter_charlist_to_table'  导出的脚本,重新创建Table-valued Function 就可以了。

原地址:http://forum.entlib.com/Default.aspx?g=posts&t=285

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值