Backuping Up and Restoring SQL Server with SMO

Author Message
 Posted 3/20/2008 4:41:20 AM
StrataFrame Developer

StrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame Developer

Group: StrataFrame Developers
Last Login: 11/6/2019 9:10:28 AM
Posts: 6,610, Visits: 6,775
There have been some inquiries as to how to backup and restore SQL Server databases through an application in the field.  The best approach that we have learned for creating a reusable backup solution is to use SMO.  We have a service that runs within our medical application that automatically backs up the end-users database to a different file name each night...since they don't always do this themselves BigGrin

You can modify this logic to backup and restore individual file groups.  But this sample will at least get you started and shows how to backup and restore a single database using SMO.

Note: You may need to adjust the output folder path and the server settings in order to get this sample to work for you.

 BackupAndRestoreSql.zip (310 views, 98.07 KB)

Post #15065
Add to Twitter Add to Facebook

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.