RESTORE DATABASE TWO FROM DISK='C:\TWO.BAK' WITH REPLACE,NORECOVERY, MOVE 'GPSTWODat' to 'E:\Program Files\Microsoft SQL Server\MSSQL\Data\GPSTESTDat.mdf', MOVE 'GPSTWOlog' TO 'E:\Program Files\Microsoft SQL Server\MSSQL\Data\GPSTESTlog.ldf'
Server: Msg 3101, Level 16, State 2, Line 1
Exclusive access could not be obtained because the database is in use.
Received the above error message while trying to restore database through query analyzer. I want to restore to TEST database from TWO.bak file while nobody is using either TWO and TEST database. I know how to restore database through SQL Enterprise Manager, but I really want to find out a way to schedule isql or osql to restore database to a backup SQL server.
Will the following statement work?
isql -U sa -P PASSWORD -S SERVERNAME -Q "RESTORE DATABASE TWO FROM DISK='C:\TWO.BAK' WITH REPLACE,NORECOVERY, MOVE 'GPSTWODat' to 'E:\Program Files\Microsoft SQL Server\MSSQL\Data\GPSTESTDat.mdf', MOVE 'GPSTWOlog' TO 'E:\Program Files\Microsoft SQL Server\MSSQL\Data\GPSTESTlog.ldf'"
Thanks in advance for any help.
Rob
Server: Msg 3101, Level 16, State 2, Line 1
Exclusive access could not be obtained because the database is in use.
Received the above error message while trying to restore database through query analyzer. I want to restore to TEST database from TWO.bak file while nobody is using either TWO and TEST database. I know how to restore database through SQL Enterprise Manager, but I really want to find out a way to schedule isql or osql to restore database to a backup SQL server.
Will the following statement work?
isql -U sa -P PASSWORD -S SERVERNAME -Q "RESTORE DATABASE TWO FROM DISK='C:\TWO.BAK' WITH REPLACE,NORECOVERY, MOVE 'GPSTWODat' to 'E:\Program Files\Microsoft SQL Server\MSSQL\Data\GPSTESTDat.mdf', MOVE 'GPSTWOlog' TO 'E:\Program Files\Microsoft SQL Server\MSSQL\Data\GPSTESTlog.ldf'"
Thanks in advance for any help.
Rob