Hi.. I don't know if anyone has done this, but I have quite a few databases I would like to restore automatically. I have a vb.net program passing variables to a stored procedure and would like the sql backup 7 to use those in the restore command... something like below:

EXECUTE master..sqlbackup '-SQL "RESTORE DATABASE [@sitename + ''_APP_'' + @DBSUFFIX]
FROM DISK = @backupfilepath WITH MOVE DATAFILES TO @dbdirectory,
MOVE LOGFILES TO @tlogdirectory, REPLACE " '
jonstahura
0

Comments

3 comments

  • Brian Donahue
    Thanks for your question. It's not something that we support directly, but the .NET Framework does have a SqlClient namespace that you can use to run queries. To do what you want to in your example, I think it's best to use a parameterized query as in this example: http://www.dotnetperls.com/sqlparameter
    Brian Donahue
    0
  • jonstahura
    thanks for the link.. i figured it out.

    I needed more single quotes... a LOT more.... and then it worked! :)
    jonstahura
    0
  • Brian Donahue
    Thanks, I'm glad that worked.
    Brian Donahue
    0

Add comment

Please sign in to leave a comment.