Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to restore using S.P

Author  Topic 

sunny_10
Yak Posting Veteran

72 Posts

Posted - 2013-03-14 : 01:38:04
Hi

How i can restore database using Stored Procedure

Thanks

ScottPletcher
Aged Yak Warrior

550 Posts

Posted - 2013-03-14 : 12:48:41
You can use a RESTORE DATABASE command inside the stored proc:


CREATE PROCEDURE ...
...
SET @db_name_to_restore = ...
SET @backup_file_to_restore = 'x:\full\path\to\backup\file\backup.bak'
RESTORE DATABASE @db_name_to_restore
FROM DISK = @backup_file_to_restore

Go to Top of Page
   

- Advertisement -