SQL Server daily full backup cycled in one week

Source: Internet
Author: User

This article is about how to full backup the SQL Server 2005 database. this solution uses the SQL Server Agent to start a job with schedule to fullback it automatically. it always have 7. bak files in recent 7days. the schedule is 2: 00 am every day. the detail is as followed:
1. Connect to the SQL Server Management Studio, find "SQL Server Agent ";

2. Add a new job;

3, find "step", then add a new step with SQL transaction.

4, find "schedules", set it to meet your requirement. I choose all days in one week here.

5. click "OK", and you can start the job for test.

 

Declare @ pWeekDay varchar (3)
Declare @ SQL varchar (200)
Select @ pWeekDay = left (datename (weekday, getdate (), 3)
Set @ SQL =''
Set @ SQL = @ SQL + 'backup DATABASE DBName TO DISK = n' S: \ DBBackup \ dbname' + @ pWeekDay
Set @ SQL = @ SQL + 'full. bak ''with noformat, INIT, NAME = n' DBName-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, STATS = 10'
Exec (@ SQL)

 

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.