How can we help you today? How can we help you today?

Running sqlbackup dynamically

Hi

I am trying out the software using sql2000 on win2003.

We have a customized backup script that is backing up our databases.
The following command fails:

exec sqlbackup '-SQL "BACKUP DATABASE ' +@dbname+' TO DISK = ''''' +@complete_filepath+''''' WITH NAME = '''''+ @BackupFile+''''', DESCRIPTION = '''''+ @Description+''''' , INIT"'END

with

Incorrect syntax near '+'.

printing the above command returns

-SQL "BACKUP DATABASE confirm_admin TO DISK = ''t:\backup\confirm_admin_full_20060506_080620.bak'' WITH NAME = ''confirm_admin_full_20060506_080620.bak'', DESCRIPTION = ''Full BACKUP at 20060506_080620.'' , INIT"

Running this commands directly in QA works fine.

Is this error to be expected?
audun
0

Comments

1 comment

  • petey
    Try the following:

    DECLARE @command nvarchar(1024)
    SET @command = '-SQL "BACKUP DATABASE ' +@dbname + ' TO DISK = ''' +@complete_filepath+''' WITH NAME = ''' + @BackupFile + ''', DESCRIPTION = '''+ @Description+''' , INIT"'

    EXEC master..sqlbackup @command
    petey
    0

Add comment

Please sign in to leave a comment.