SQL Server – Error – Msg 902 – “To change the NAME, the database must be in state in which a checkpoint can be executed”

Background

Trying to rename a database, but ran into the error noted below

 

SQL

Command Issued


exec sp_renamedb [TSD08282017], 'REDWOOD_TSD_PC31'

 

Error Message


Msg 902, Level 16, State 1, Line 5
To change the NAME, the database must be in state in which a checkpoint can be executed.


TroubleShooting

Get Database State


declare @database sysname

set @database = 'TSD08282017'

select 
	  tblSD.[name]
	, tblSD.[is_read_only]
from   sys.databases tblSD
where  tblSD.[name] = @database

Output

Database came back as readonly

Remediation

Change Database State


alter database [TSD08282017] set READ_WRITE
   with rollback immediate

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s