Announcement Banner
UNSOLVED

mhaupt2

updated

17 years ago

M

mhaupt2

1 Rookie

•

64 Posts

0

1159

May 22nd, 2009 13:00

Re-directed restore an active SQL database using the nsrsqlrc command

I have successfully been able to do a command line re-directed restore of a SQL database from one server to another. But it only works if the restored database is not active. If I detach it from SQL and run the command line restore, it will overwrite the database fine and re-attach automatically. But it will not work when it is attached in SQL. It tells me that exclusive access could not be obtained because the database is in use. Using SQL 2000 - SP4.

I am trying to do this so that I can do a scheduled restore (via a batch file) once a month overwriting a specific database on a specific server which our developers use to run reports from.

Any ideas how to overwrite an active database via the command line. I even tried with the Networker Client and it still wouldn't restore over an active database.

Mike
  • DavidHampson

    2 Intern

    •

    1080 Posts

    490

    0

    Posted May 25th, 2009 01:00

    One of the requirements to do a restore of a SQL database is to be logged on in single user mode which is why you cannot recover when the database is active. The only way you can achieve what you want is to include the stopping and restarting of the database within the script.