Error when changing the collation of a database

Recently I had to change the collation of a database. That resulted in an error message:

The database could not be exclusively locked to perform the operation.

I found the solution at http://www.stolenbit.com/2008/10/database-could-not-be-exclusively.html. To change the collation in this case you have to put the database in single user mode first:

ALTER DATABASE <database_name> SET SINGLE_USER WITH ROLLBACK IMMEDIATE 
ALTER DATABASE <database_name> COLLATE <target_collation_name like SQL_Latin1_General_CP1_CI_AS>
ALTER DATABASE <database_name> SET MULTI_USER

Kimberly Tripp has more on this subject at http://www.sqlskills.com/BLOGS/KIMBERLY/post/Changing-Database-Collation-and-dealing-with-TempDB-Objects.aspx.

posted @ Thursday, September 16, 2010 3:56 PM

Print