Data Backup

Total Post:37

Points:259

 2042  View(s)
Ratings:
Rate this:
How to take backup of sel server 2005
  1. Re: Data Backup

    In Management Studio select database >> right click on selected database >> tasks >> back up

  1. Re: Data Backup

    Write down following code snippet in c# to take backup. One thing remeber that creadential should be changed..

        using System;
        using System.Data;
        using System.Collections;
    using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Smo;
    class Program { static void Main(string[] args) { BackupDeviceItem bdi = new BackupDeviceItem("AdventureWorks.bak", DeviceType.File);
    Backup bu = new Backup( ); bu.Database = "AdventureWorks"; bu.Devices.Add(bdi); bu.Initialize = true;
    // add percent complete and complete event handlers bu.PercentComplete += new PercentCompleteEventHandler(Backup_PercentComplete); bu.Complete +=new ServerMessageEventHandler(Backup_Complete);
    Server server = new Server("localhost"); bu.SqlBackup(server);
    Console.WriteLine(Environment.NewLine + "Press any key to continue."); Console.ReadKey( ); }
    protected static void Backup_PercentComplete( object sender, PercentCompleteEventArgs e) { Console.WriteLine(e.Percent + "% processed."); }
    protected static void Backup_Complete(object sender, ServerMessageEventArgs e) { Console.WriteLine(Environment.NewLine + e.ToString( )); } }

      Modified On Mar-29-2018 04:10:13 AM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.