Information Technology Knowledge Base

August 23, 2006

Rename SQL Server database

Filed under: Microsoft Sql server — Tijs Vandormael @ 9:34 am

If you ever find yourself in a situation where you need to rename a SQL Server database you could use the following 3 statements to do the job:

-- Make sure that you are the only user accessing the db
EXEC sp_dboption 'old name', 'Single User', 'TRUE'
-- Rename the db
EXEC sp_renamedb 'old name', 'new name'
-- Allow other users to login again
EXEC sp_dboption 'new name', 'Single User', 'FALSE'

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress