Database Dump Script


rem make sure the dump device exists

  isql -U%1 -P%2 -S%3 -Q"sp_helpdevice" -od:\dbmaint\SQL_devices.out -b
  find "%4dump" d:\dbmaint\SQL_devices.out 
  if errorlevel 1 set maintenance_status=stop
  if %maintenance_status%==go goto :device_found
  echo no dump device found
  echo Create the device and restart the maintenance process
  goto :end

:device_found

rem archive the dumps

  if not exist d:\MSSQL\backup\%4dump.old goto :no_old 
  del d:\MSSQL\backup\%4dump.old
:no_old
  if not exist d:\MSSQL\backup\%4dump.dat goto :no_dat
  rename d:\MSSQL\backup\%4dump.dat %4dump.old
:no_dat
  isql -U%1 -P%2 -S%3 -Q"DUMP DATABASE %4 TO %4dump WITH INIT"
-od:\dbmaint\%4dump.out 

:end