ERROR:The database could not be exclusively locked to perform the operation
2012-03-18 13:29 Wizardlsw 阅读(1653) 评论(0) 编辑 收藏 举报今天在导数据时遇到几个问题,因为一个是英文操作系统,一个是中文操作系统,两个默认的不一样。我想现在就统一在数据库级别将中文的那个Collation 从 Chinese_PRC_CI_AS 改为 SQL_Latin1_General_CP1_CI_AS(英文系统默认)。
但当我运行:
ALTER DATABASE QinBide COLLATE SQL_Latin1_General_CP1_CI_AS
报出错误如下:
Msg 5030, Level 16, State 2, Line 1
The database could not be exclusively locked to perform the operation.
Msg 5072, Level 16, State 1, Line 1
ALTER DATABASE failed. The default collation of database 'XXXX' cannot be set to Chinese_PRC_CI_AS.
所在环境:
OS: Windows 7 Professional English X64
DB: Sql Server 2008 R2
解决办法:
ALTER DATABASE QinBide SET SINGLE_USER WITH ROLLBACK IMMEDIATE
go
ALTER DATABASE QinBide COLLATE SQL_Latin1_General_CP1_CI_AS
go
ALTER DATABASE QinBide SET MULTI_USER
go
引用:
http://www.cnblogs.com/psunny/archive/2010/09/28/1837835.html
http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL-Server-2005/Q_23422696.html
不过还有另外一个问题,对于原有的数据表字段,对应的Collation也是 Chinese_PRC_CI_AS,但我不知道如何统一一次性修改,由于表的数量不多,我暂时就直接进入各个表进行修改(下回请教公司DBA一下):
列属性 –> Collation –> Restore Default
如下图: