Sunday, March 11, 2012

Back & Restore of Multiple Databases

Hey all,

I was wondering if I could get some help on something thats got me really stuck!

At the moment we have in our product some SQL scripts that will backup & restore a database whenever required.

We've now added another database (an audit database) so we need to change those scripts to include this database.

The backup script seems fairly easy to change as ive added another 'BACKUP DATABASE' line that points to the same file.

The problem I am having is that when it comes to restore the 2 databases I get a whole load of errors, most of them complaining that the '.mdf' & 'log' files can't be overritten because they are already in use by the previous database (since I restore the 'data' database first and then the 'audit' database)

I've tried the 'MOVE' command but it doesn't seem to support the 'RESTORE' option?

Is there anyway I can get the backup to retain the '.mdf' & '.log' file locations so that the restore simply puts them back in the same place or is there another command that can help with my situation?

Thanks in advance!

It sounds like the 'data' database has references and links to the 'audit' database.

Try restoring the 'audit' database first, and then the 'data' database.

If I'm completely 'off base', let me know and we will try other tactics to help you.

|||I think you can use the REPLACE option of RESTORE to do this.|||

if I understand Properlly then try this

Go to Enterprise Manager,

select your server and right click your database,

then you see a option back up

just do backup

|||

Thanks everyone, but I sorted it myself.

The problem was that SQL didn't know which of the databases to restore so I had to use the 'PARTIAL, FILE = 1' extra commands in order to instruct SQL which database to restore and from what position.

No comments:

Post a Comment