Solution 1: Set to single user, then restore
Alter Database [<Database Name>]
SET SINGLE_USER With ROLLBACK IMMEDIATE
RESTORE DATABASE [<Database Name>] FROM DISK = N'E:\Databases\SampleDatabase.bak' WITH FILE = 1, MOVE N'Tfs_Silverlight' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\SampleDatabase.mdf', MOVE N'SampleDatabase_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\SampleDatabase.LDF', NOUNLOAD, REPLACE, STATS = 10
GO
Solution 2: Restart SQL Server service
1. Start -> Run and type in services.msc
2. Right click on the SQL Server instance (MSSQLSERVER), click Stop and then Start the service
3. Do the restore process
No comments:
Post a Comment