Options

Dynamic sql for the T-SQL script

doradora Posts: 2
edited August 28, 2007 8:31PM in SQL Backup Previous Versions
I am trying to insert the T-SQL script into my stored procedure that does a backup of all the databases. waht i need to accomplish in the script is to be able to pass teh name of the database and the path name dynamically to the sql statement. How do I pass those values in the script ?
I tried somethig like this but it errored out. Could you please advice.

EXECUTE master..sqlbackup N'-SQL "BACKUP DATABASE "'+ @DBNAME + '" TO DISK = "' +@physicalName+ '"
WITH COMPRESSION = 1, ERASEFILES = 2, VERIFY"'

Thanks,
Dora.

Comments

Sign In or Register to comment.