Hi,
i have a job that restores a database every night. The job fails if someone is logged onto the database. Its a development database. I was wondering if there is a command that i can use to kick everyone off the database before the restore?
any help is appreciated.
Hi
We use the following:
USE Master
Go
ALTER DATABASE <DBName> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
--RESTORE DATABASE
GO
ALTER DATABASE <dbName> SET MULTI_USER WITH ROLLBACK IMMEDIATE
Go
|||Thanks. i think this will be helpful
what does 'with rollback immediate' do?
|||Hi
WITH <termination>
Specifies when to roll back incomplete transactions when the database is transitioned from one state to another. (BOL)
No comments:
Post a Comment