DATA BACKUP

Amresh Kushwaha

Total Post:38

Points:266
Posted by  Amresh Kushwaha
 1580  View(s)
Ratings:
Rate this:
How to take backup of sel server 2005
  1. Uttam Misra

    Post:125

    Points:897
    Re: Data Backup

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

  1. Amresh Kushwaha

    Post:38

    Points:266
    Re: Data Backup

    I want to command

  1. Awadhendra Tiwari

    Post:126

    Points:882
    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( ));
    }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!