What are the challenges you face when working across database platforms? Take the survey

error with restore job

gaelgael Posts: 20
edited March 21, 2006 9:08AM in SQL Backup Previous Versions
I'm creating a (simple) job to restore DB1 > DB2 (sql2k):

p:\backup\DB1.sqb is ok.
DECLARE @exitcode int
DECLARE @sqlerrorcode int
exec master..sqlbackup N'-SQL "RESTORE DATABASE DB2 FROM DISK = ''P:\backup\DB1.sqb''  WITH  RECOVERY, REPLACE"' , @exitcode OUTPUT, @sqlerrorcode OUTPUT
IF (@exitcode <>0) OR (@sqlerrorcode <> 0)
  RAISERROR ('Restore job failed with exitcode: %d  SQL error code: %d', 16, 1, @exitcode, @sqlerrorcode)

and outpout file return :
Job 'RestoreJob' : Step 1, 'restore' : Began Executing 2006-03-21 14:00:43

SQL Backup (DLL v4.1.0.207)                                                                                                     
Restoring rDB2 (database) from: 

VDI error 1010: Failed to get configuration from server.  Check that the SQL Server instance is running, and that you have the 
SQL Server Systems Administrator server role.  Error code:  (-2139684861: The api was waiting and the timeout interval had 
SQL error 3013: RESTORE DATABASE is terminating abnormally.
SQL error 3101: Exclusive access could not be obtained because the database is in use.

SQL Backup exit code: 1010
SQL error code: 3101
name                                                            value                                        
---------------------------------------------------------------- exitcode                                                         1010
sqlerrorcode                                                     3101
filename01                                     P:\backup\DB1.sqb

Msg 50000, Sev 16: Restore  job failed with exitcode: 1010  SQL error code: 3101 [SQLSTATE 42000]

can you help me?



  • Options
    peteypetey Posts: 2,358 New member
    One or more users were using that database at the time of the restore. Run sp_who or sp_who2 to see who's using the database.
    Peter Yeoh
    SQL Backup Consultant Developer
    Associate, Yohz Software
    Beyond compression - SQL Backup goodies under the hood, updated for version 8
  • Options
    Huh... no, any user on the database... but I solve the problem.
    DECLARE @exitcode int
    DECLARE @sqlerrorcode int
    exec master..sqlbackup N'-SQL "RESTORE DATABASE [DB2]  FROM DISK = ''P:\backup\DB1.sqb''  WITH  RECOVERY, MOVE ''DB1'' TO ''E:\MSSQL\Data\DB2.mdf'', MOVE ''DB1_log'' TO ''E:\MSSQL\Data\DB2_log.ldf'', REPLACE"', @exitcode OUTPUT, @sqlerrorcode OUTPUT
    SELECT @exitcode returnExitCode,
    	@sqlerrorcode returnSQLErrorCode

    and that's right.. :roll:
Sign In or Register to comment.