Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Routine to create a SQL Server Backup

Posted on 2004-04-25
2
Medium Priority
?
1,126 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

636 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