Search code examples
sql-serverdatabasedatabase-restore

While Restoring the Sql Server Data base Status is Stuck


I am facing one problem ie. I create one data base... and then I restored it... the back up is from the existing data base only.. after successfully restored old one ie. parent one is showing that

"BRPL_Payroll _31-01-2014" (Restoring.........)

like above it is showing....

and then i execute the below query..

RESTORE DATABASE BRPL_Payroll _31-01-2014 ;WITH RECOVERY

but here it is showing that incorrect syntax at '-'

I think my data base name is having some date 31-01-2014 how can i execute the above query...


Solution

  • You can easily restore a database Using the UI and before pressing OK to restore you select Script and SQL-Server will show you the script (Query) you need to run in order to execute the step.

    Database restore

    If you don't have direct access I can give you a restore script which works to restore a database from file. But you have to replace of course the path to your DB and your DB Name :

    USE [master]
    ALTER DATABASE [YURDATABASENAME] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
    RESTORE DATABASE [YURDATABASENAME] FROM  DISK = N'C:\your\backup\path\backup.bak' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 5
    ALTER DATABASE [YURDATABASENAME] SET MULTI_USER
    
    GO