At work, you often encounter backing up an application database. At the beginning, you may manually back up the database once a day, but after a long time, you may think of automatic backup, the following describes the automatic backup method that I often use.
- Choose Enterprise Manager> Manage> SQL server proxy.
- Create a new job and take the job name as needed. For example, for data backup, select sa as the owner. You can also select another user, provided that the user has the permission to execute the job;
- Click the step tab to go to the step panel. Create a step. You can enter the step name as needed, such as step 1. The default type and database do not need to be modified. Write the following statement in the command: backup database [database name] to disk = n' F: \ data \ database backup 'with noinit, NOUNLOAD, NAME = n' database backup ', NOSKIP, STATS = 10, NOFORMAT
- Note: The Database Name, DISK = (here you need to enter the path and the Name of your database backup), and the Name = can be entered at will.
- Click the scheduling tab to go to the scheduling panel, create a new scheduling task, enter the name as needed, and select "appear repeatedly". Click "change" to select the desired scheduling task. Such as every day, every 2 days, every week, and every month. Set as needed;
- After confirming, do not forget one thing. Right-click the job you just created and start the job. If there is no problem with your job, a message indicating that the job is successfully executed will be displayed, corresponding backup files appear on your disk;
- Another important problem is that your SQL server agent server has been started.
If we need to generate a new backup based on the daily date, we can differentiate the backup files. At this time, we need to modify the SQL statement just now. Reference instance: declare @ filename nvarchar (100) set @ filename = 'f: \ AddIn \ backup \ data' + convert (char (10), getdate (), 112) print @ filename backup database [addin] to disk = @ filename with noinit, NOUNLOAD, NAME = N 'addin BACKUP ', NOSKIP, STATS = 10, NOFORMAT