Tuesday, March 27, 2012

backup SQL server databases

Hi,
At the moment I use a SQL job to make dumps of SQL server databases to
the file system. A few hours later I backup these files to tape.
Now I want to connect both processes. In the backup program I can
start .bat files and catch the error level of the batch file. But is
it possible to start a SQL server job from command line and to catch
the outcome of the SQL backup process (so that the backup to tape only
starts when the backup to disk succeeds)?
Many thanks in advance,
Stijn.You can start a job using sp_start_job. But jobs are executed asynchronously. This means that you
cannot reliably "wait" until end of execution and then report back the error. So, I suggest you grab
whatever TSQL you have in your job, put it in a script file and execute that using SQLCMD.EXE (or
OSQL.EXE depending on version of SQL Server).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
<stijn.calders@.gmail.com> wrote in message
news:1183967597.475367.257660@.o61g2000hsh.googlegroups.com...
> Hi,
> At the moment I use a SQL job to make dumps of SQL server databases to
> the file system. A few hours later I backup these files to tape.
> Now I want to connect both processes. In the backup program I can
> start .bat files and catch the error level of the batch file. But is
> it possible to start a SQL server job from command line and to catch
> the outcome of the SQL backup process (so that the backup to tape only
> starts when the backup to disk succeeds)?
> Many thanks in advance,
> Stijn.
>

No comments:

Post a Comment