1. Create the following stored procedure on the data to be backed up:
CREATE PROCEDURE [dbo].[Process name] AS
declare
@filename nvarchar(100),--file name
@NowDay int --Set the time
set @filename='F:JXXdata'+cast(Day(GetDate()) as varchar(2))+'.dat' --File path and file name
Set @NowDay=Day(GetDate())
if (@NowDay>=20) or (@NowDay<=10) --Back up from 20 this month to 10 next month
begin
print @filename BACKUP DATABASE [database name () you can also set parameters] TO DISK = @filename WITH INIT, NOUNLOAD, NAME = N'XX data backup', NOSKIP, STATS = 10, NOFORMAT
end
The stored procedure must be debugged correctly
2 , enter the Enterprise Manager -> Management -> SQL Server Agent -> Job, create a new job, and choose the job name as you like, for example: data backup, the owner selects sa, of course you can also select other users, provided that the user has executed Permissions for the job;
3. Name it in the step - select the database to be backed up - enter exec('process name') in the command
4. Select recurring in the schedule - change - select every day - enter the time yourself
5 .After the test - finally import the script into the server
6. Enable the SqlServer Agent service in the SQlServer service manager