Execute SQL Server database backup and SQL database backup using Windows batch processing commands
Create mybackup. bat and enter the following content to directly run the script to start automatic database backup. You can also add the script to the windows Task Plan for execution.
@ Echo offset path = % path %; C: Program Files \ Microsoft SQL Server \ 80 \ Tools \ Binnecho Database Backup Start> E: \ DataBaseBAK \ Task Plan Completion record .txt date/t> E: \ DataBaseBAK \ Task Plan Completion record .txt time/t> E: \ DataBaseBAK \ Task Plan Completion record .txtisql.exe-S 127.0.0.1-U sa-P sa-I my. sqlecho Database Backup completed> E: \ DataBaseBAK \ Task Plan Completion record .txt date/t> E: \ DataBaseBAK \ Task Plan Completion record .txt time/t> E: \ DataBaseBAK \ Task Plan Completion record .txt echo. echo. echo. database Backup completed echo. echo. rem pause
Create an SQL Script: mybackup. SQL in the same folder.
The content is as follows:
----------------------------------------------------------------------------
DECLARE @name varchar(50)DECLARE @datetime char(14)DECLARE @path varchar(255)DECLARE @bakfile varchar(255)set @name='V5HQS'set @datetime=CONVERT(char(8),getdate(),112) + REPLACE(CONVERT(char(8),getdate(),108),':','')set @path='E:\DataBaseBAK'set @bakfile=@path+''+@name+'_'+'bak_'+@datetime+'.BAK'backup database @name to disk=@bakfile with name=@namego
The above section describes how to execute SQL Server database backup using Windows batch processing commands. I hope to help you with the above!
Articles you may be interested in:
- Code for automatic backup and cleanup of mysql databases using batch processing
- One-click Backup of MySQL database Batch Processing
- Automatic Backup of mssql server database and compressed batch processing script
- Batch backup of mssql database
- MySQL backup and restoration database Batch Processing
- Backup and restoration tools for oracle databases written in batches
- Batchcompute command BAT to back up MySQL database
- Back up databases remotely using batch files (data in recent days)