To create a database backup job by using SQL Server Management Studio

Source: Internet
Author: User
Tags getdate management studio sql server management sql server management studio

The SQL Server job is simply to execute the specified script at the prescribed time, which describes how to create a job backup database with SSMs (SQL Sever 2008).

(0) Assume that the database you are backing up before you create the job already exists; second, you have started the SQL Sever agent (which is typically off)

(1) Creating SQL Server Agent Jobs

(1.1) New job, output general information

such as: Enter the job name (for example: Backupjobtest), where the owner and the category are the default, enter the description (just like writing code to write comments, the benefit of people self-interest)

(1.2) Set up job execution steps

Click the Step Properties tab on the left "select Page" and click the "New" button

In the Job Step Properties window, type selection (T-SQL), select the database to be backed up, and paste the debug SQL backup script, as I was writing for the first time, post an example here, readers can refer to the changes themselves:

--Assign SQL script to variable declare @SqlBackupDataBase as nvarchar set @SqlBackupDataBase =n ' BACKUP DATABASE yourdatabasename to DISK = ' E:\DBBackup\YourDataBaseName-' +convert (varchar (one), GETDATE (), +replace) (CONVERT (varchar), GETDATE () , 108), ': ', ' ') + '. Bak '--backup file format: Yourdatabasename-20140626233410.bakprint @SqlBackupDataBase--Print it out (for easy debugging, can be omitted) EXEC sp_executesql @SqlBackupDataBase--Call system stored procedure, execute SQL

Note: The third parameter of the CONVERT () function is the time style ID; Replace the colon in time with the Replace () function (because the file name in Windows cannot contain the character)

Time format and ID table reference: W3school

(1.3) Set up the job execution plan

On the Schedule tab, click the New button to create a new schedule:

After setting up, click "OK" button, the other three properties "alert", "Notification", "target" can be set by themselves if necessary, no longer described here.

Once you have finished setting up your plan, click the "OK" button on your supervisor and the job is created.

(2) Manual verification of the correctness of job execution

Right-click the job you just created under the Job node ("Backupjobtest" in the figure) and select ' Job Start step (T) '

The execution results are as follows, indicating success:

Click "View History (V)" To view the log:

Original: http://www.cnblogs.com/January/p/3811524.html

To create a database backup job by using SQL Server Management Studio

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.