You can use the restore command for restoring
like this:
create proc as restoring
as
begin
Restore database ‘mydatabasename’
From disk=’path dirrectory’
With replace
end
but please note your back up file name must have same name as your database file name or
if not, you need to assign back up files to database file explicity:
create proc resotre as
begin
Restore database ‘mydatabasename’
From disk=’path dirrectory’
With replace
Move’filename backup’ to ‘dirictory of database file’
Move ‘filename backup’ to ‘dirictory of database file’
end
and for calling proc easily
call it in sql command parameter:
SqlCommand testCMD = new SqlCommand
("TestProcedure", PubsConn);