Red Gate forums :: View topic - Restore with dynamic fields
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Backup 7
SQL Backup 7 forum

Restore with dynamic fields

Search in SQL Backup 7 forum
Post new topic   Reply to topic
Jump to:  
Author Message
jonstahura



Joined: 28 Sep 2012
Posts: 13

PostPosted: Fri Oct 19, 2012 8:14 pm    Post subject: Restore with dynamic fields Reply with quote

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 " '
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6582

PostPosted: Mon Oct 22, 2012 4:25 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
jonstahura



Joined: 28 Sep 2012
Posts: 13

PostPosted: Mon Oct 22, 2012 5:31 pm    Post subject: Reply with quote

thanks for the link.. i figured it out.

I needed more single quotes... a LOT more.... and then it worked! Smile
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6582

PostPosted: Tue Oct 23, 2012 8:50 am    Post subject: Reply with quote

Thanks, I'm glad that worked.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group