Friday, 9 January 2015

How to change database to single user mode


HOW TO CHANGE DATABASE TO SINGLE USER MODE
ALTER DATABASE [YOUR_DATABASENAME]
SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO

-- WITH NO WAIT WILL ONLY SET THE DATABASE TO SINGLE USER MODE IF ALL TRANSACTION HAVE BEEN COMPLETED.IT WILL NOT WORK IF THERE IS OPEN TRANSACTION

ALTER DATABASE [YOUR_DATABASENAME]
SET SINGLE_USER WITH NO_WAIT
GO

-- HOW TO CHANGE DATABASE TO MULTIPLE USER MODE
 ALTER DATABASE [YOUR_DATABASENAME]
 SET MULTI_USER WITH ROLLBACK IMMEDIATE
 GO


-- HOW TO CHANGE DATABASE TO READ ONLY
ALTER DATABASE  [YOUR_DATABASENAME]
SET    READ_ONLY

-- HOW TO CHANGE DATABASE TO READ WRITE
ALTER DATABASE  [YOUR_DATABASENAME]
SET    READ_WRITE

No comments:

Post a Comment