Monday, 6 June 2011

Restoring a SQL database with active users

Sometimes it is necessary to restore a database that has users currently active inside it. Use the following SQL in order to achieve this...

USE [master]
GO
ALTER DATABASE [myDatabaseName] SET  SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

RESTORE DATABASE [myDatabaseName] FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\myDatabaseName.bak' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 10
GO


USE [master]
GO
ALTER DATABASE [myDatabaseName] SET  MULTI_USER WITH ROLLBACK IMMEDIATE
GO

2 comments:

  1. For such issue there is mdf recovery. It can work out trouble with corrupted or lost sql databases. The software works under any Windows OS. It uses effective methods of restoring files from any SQL Server versions.

    ReplyDelete
  2. Thanks for sharing the nice video. Here is the tool would be the the user in SQL Database Recovery and restore Process. No technical skill required.

    http://www.recoverfilesdata.com/sql-database-mdf-recovery.html

    Thanks

    ReplyDelete

How to by pass the Jaguary X-Type enter security pin screen after changing battery

How to bypass security code on Jaguar X-Type touchscreen Satellite Navigational units. Just hold the skip track, AMEM and PTY buttons ...