Execute SQL Server database backup and SQL database backup using Windows batch processing commands

Source: Internet
Author: User
Tags mssql server

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.