Original: Create a database backup job using 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:
--Assigning a SQL script to a variableDeclare @SqlBackupDataBase as nvarchar( +)Set @SqlBackupDataBase=N'BACKUP DATABASE yourdatabasename to DISK ="'E:\DBBackup\YourDataBaseName-'+CONVERT(varchar( One),GETDATE(), the)+REPLACE(CONVERT(varchar( A),GETDATE(),108),':',"')+'. bak" "--backup file format: Yourdatabasename-20140626233410.bakPrint @SqlBackupDataBase --print out (to be easy to debug, omit)execsp_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:
To create a database backup job by using SQL Server Management Studio