C# .NET - Database Backup using stored procedure

Asked By s j on 01-Feb-12 06:31 AM


Hi,

In my web application ( using C#.Net & SQLServer 2008), i  have to get database backup from database using stored procedure and store it in my folder every day in a button click event.

How can we do this..






Cheers,
Samantha.
Reena Jain replied to s j on 01-Feb-12 06:37 AM
hi,

I have created procedure that will backup your database when you execute it

USE AdventureWorks2008R2;
GO
BACKUP DATABASE AdventureWorks2008R2
TO DISK = 'Z:\SQLServerBackups\AdventureWorks2008R2.Bak'
   WITH FORMAT,
  MEDIANAME = 'Z_SQLServerBackups',
  NAME = 'Full Backup of AdventureWorks2008R2';
GO


Thanks
Suchit shah replied to s j on 01-Feb-12 06:48 AM
Do a CREATE PROCEDURE command with the script to do your backups the way you see fit, then create a job and in the steps do a EXEC storedprocname and pass whatever variables (if any) you need for it to work.  Save the step and schedule the job.  Let us know if you need information about specific steps.