Showing posts with label MSSQL. Show all posts
Showing posts with label MSSQL. Show all posts

Wednesday, April 22, 2009

DataBase could not be exclusively Locked when renaming a database

The problem is due to other users using the database. To resolve the problem, you set the database to be used only by yourself. After the rename operation, you need to reset it back to be usable by other users. It is a common courtesy to inform all users prior to doing this operation.

ALTER DATABASE DBNAME SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
SP_RENAMEDB @dbname = 'old_name' ,
@newname = 'new_name'
Go
ALTER DATABASE NEWDBNAME SET MULTI_USER -- set back to multi user
GO

Tuesday, March 10, 2009

The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported...

This problem frequently occurs when you just restored a database, but service brokers are broken or lost.

To resolve this problem.

alter database xxxx set NEW_BROKER

Alternatively,

1. Go to Programs -> Microsoft Sql Server 2005 -> Configuration Tools -> Sql Server Surface Area Configuration -> Surface Area Configuration for Features.
2. Locate "Service Broker" under the database engine and enable it.

Wednesday, July 16, 2008

How to Restore a MSSQL backup (.bak)

Run the command in MSSQL to restore a .bak file

RESTORE DATABASE [abc]
FROM DISK = 'C:\backup_200807102327.bak'
with move 'abc' to 'C:\Database\abc.mdf',
move 'abc_LOG' to 'C:\Database\abc.LOG',
Replace
GO