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.
| Author |
Topic |
|
honey_191
Starting Member
49 Posts |
Posted - 2008-02-04 : 02:53:40
|
| I wrote a Sp to take the backup,2 i/p parameter(one for the backup type and second for the database name).After that I have to create 2 jobs.one job is to take the backup,in the 2nd step of the job i have to call 2nd job which has to restore the backup which was taken recently..I got the stored procedure for taking the backup.I need to write a stored procedure for restoring the backup which i was taken recentlyI think by using system tables(msdb) we have to retive the backupfile path.backup file path is in system table(msdb)-backupmediafamily and the column name is [physical_device_name]Can anybody help me in writing the stored procedures for restore |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2008-02-04 : 14:30:50
|
| DECLARE @myBackUpSetID INT,@dbName VARCHAR(100),@serverName VARCHAR(100)SET @dbName = 'MyDB'SET @serverName = 'MyServer'select @myBackUpSetID = max(bs.backup_set_id)from msdb.dbo.backupset bswhere bs.database_name = @dbnameand bs.type = 'D'and bs.server_name = @@servernameJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
|
honey_191
Starting Member
49 Posts |
Posted - 2008-02-04 : 15:57:50
|
| do i need to write the restore command after that?restore database @dbnamefrom disk=?Which path i have to give here? |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-02-04 : 23:27:05
|
| Yes, you can get file path from msdb.dbo.backupfile. |
 |
|
|
|
|
|