Solved

Routine to create a SQL Server Backup

Posted on 2004-04-25
2
1,037 Views
Last Modified: 2010-04-05
I need the code (and the uses clause) to start a SQL Server backup (I will pass the Db and the Path on the server to store the backup file) I have seen the VB DMO example and I can post it here but so far I could not translate it.  It must be a full backup and it must overwrite any existing file if the names match.

One VB code example is here:
http://www.schemamania.org/jkl/booksonline/SQLBOL70/html/9_dmoe01_5.htm

Thanks,
Roberto.

0
Comment
Question by:rmaranhao
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 250 total points
ID: 10913421
This is what I was using for BACKUP SQL Server.

//----------------------------------------------------------------
procedure TFArchiw.Button1Click(Sender: TObject);
var
  Save_Cursor: TCursor;
begin
  if not DirectoryExists(ExtractFileDir(Edit1.Text)) then
    if not CreateDir(ExtractFileDir(Edit1.Text)) then
      begin
      ModalResult := mrNone;
      exit;
      end;
  Update;
  Save_Cursor := Screen.Cursor;
  Screen.Cursor := crHourglass;
  with DM2.ADOCmd do
    begin
    CommandText := 'ArchiwEx';
    Parameters.Refresh;
    Parameters.ParamByName('@fname').Value := Edit1.Text;
    Parameters.ParamByName('@mode').Value := 2;
    Prepared := True;
    Execute;
    end;
  Screen.Cursor := Save_Cursor;
end;


//----------------------------------------------------------------
CREATE PROCEDURE ArchiwEx @fname varchar(260), @mode int  AS
IF @mode = 0
      BEGIN
      BACKUP DATABASE yourdbname TO DISK = @fname
      END
IF @mode = 1
      BEGIN
      BACKUP DATABASE yourdbname TO DISK = @fname  WITH DIFFERENTIAL
      END
IF @mode = 2
      BEGIN
      BACKUP DATABASE yourdbname TO DISK = @fname WITH INIT
      END
IF @mode = 3
      BEGIN
      BACKUP DATABASE yourdbname TO DISK = @fname  WITH DIFFERENTIAL, INIT
      END
GO
SET QUOTED_IDENTIFIER  OFF    SET ANSI_NULLS  ON
GO
0
 
LVL 5

Author Comment

by:rmaranhao
ID: 10913446
Thanks mokule. I had never found the "to disk" clause.....
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question