SQL Database Backup Script
declare @IDENT INT, @sql varchar(1000), @DBNAME VARCHAR(200)
select @IDENT=min(DBID) while @IDENT is begin SELECT @DBNAME = NAME FROM /*Change disk location here as required*/ SELECT @SQL = PRINT @SQL EXEC (@SQL) select @IDENT=min(DBID) end |
DOS Batch files to backup the databases
@echo off c: if not exist c:\SQLBackup\Logs MD C:\SQLbackup\Logs if not exist c:\SQLBackup\Backup MD C:\SQLbackup\Backup cd c:\SQLBackup Echo Backup Started >> c:\SQLBackup\Logs\SQLBAckup.log Date /T > c:\SQLBackup\Logs\SQLBAckup.log Time /T >> c:\SQLBackup\Logs\SQLBAckup.log Echo. echo *************************************************************************** >> c:\SQLBackup\Logs\SQLBAckup.log isql -S (local)\Express -E -i c:\sqlbackup\backup.sql >> c:\SQLBackup\Logs\SQLBAckup.log echo *************************************************************************** >> c:\SQLBackup\Logs\SQLBAckup.log echo. Date /T >> c:\SQLBackup\Logs\SQLBAckup.log Time /T >> c:\SQLBackup\Logs\SQLBAckup.log echo Backup Finished >> c:\SQLBackup\Logs\SQLBAckup.log echo. echo *************************************************************************** >> c:\SQLBackup\Logs\SQLBAckup.log |
Folders will look like,
Schedule it on Windows Task Scheduler
That's it the SQL Server 2005 / 2008 Express Edition database backup is automated now!
1 comment:
I feel SQL and other critical aspects have proved itself always useful in providing solutions to accidental or even tailor made database problems.
SQL Server Load Rest API
Post a Comment