Hi All,
I have a SQLServer2000 server with WIN2000. Everyday, a database backup file, which is zipped, gets FTP'ed from Zurich. My job is to unzip the file and restore the database. I was trying to automate this process using perl. I have written the unzip part and the database restore part of the code. It is working fine. But I would like to enhance the code by adding in some error correction methods. For example, a SQLServer Database Restore fails if the users have logged onto that database and the following is the error it generates. ------------- Restore Error ---------------------- DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL Server]Exclusive access could not be obtained beca use the database is in use. (SQL-37000) [Microsoft][ODBC SQL Server Driver][SQL Server]RESTORE DATABASE is terminating abnormally. (SQL-37000)(DBD: st_execute/S QLExecute err=-1) at unzipkorvas.pl line 61, <UNZIP> line 6. ------------- Restore Error ---------------------- I dont know if I'm doing it right, but I'm not able to trap the outcome of the execute function. (ie, $edmsth->execute() ; ) and all I seem to be getting for the errstr() and err() is this "THe error string is : THe error number is : ". Does anyone have any suggestions. Please note that I'm not an expert in Perl. Thanks, gopi my $edmdbh = DBI->connect("dbi:ODBC:Korvas","sa","limbo"); my $edmsth = $edmdbh->prepare (qq [RESTORE DATABASE KORVAS_CGN FROM DISK = 'E:\\DBUPLOAD\\KORVAS_UWS_Dump' WITH FILE = 1, NOUNLOAD, STATS = 10, RECOVERY , REPLACE , MOVE 'KORVAS_UWS_Data' TO 'F:\\mssql2k\\data\\KORVAS_UWS.mdf', MOVE 'KORVAS_UWS_Log' TO 'F: \\mssql2k\\TLog\\KORVAS_UWS_log.ldf']); printf LOGFILE " \n\nThe Restore Process Started \@ " ; printf LOGFILE scalar localtime(); $edmsth->execute() ; printf LOGFILE "THe error string is : ", $edmsth->errstr() ; printf LOGFILE "THe error number is : ", $edmsth->err() ;