USE msdb ;
GO
EXEC dbo.sp_add_job
@job_name = N'Daily Reset of LogIn User Data';
GO
EXEC sp_add_jobstep
@command = N'UPDATE COMMAND',
@retry_attempts = 5,
@retry_interval = 5 ;
GO
EXEC dbo.sp_add_schedule
@schedule_name = N'RunDaily',
@freq_type = 4,
@active_start_time = 000000 ;
USE msdb ;
GO
EXEC sp_attach_schedule
@job_name = N'Daily Reset of LogIn User Data',
@schedule_name = N'RunDaily';
GO
EXEC dbo.sp_add_jobserver
@job_name = N'Daily Reset of LogIn User Data';
GO
我无法弄清楚如何在@command
;
我的命令是
UPDATE MyUserTable SET IsActive='N' WHERE IsActive='Y'
答案 0 :(得分:1)
你可以这样做:
DECLARE @UpdateCommand NVARCHAR(200)
SET @UpdateCommand = 'UPDATE MyUserTable SET IsActive=''N'' WHERE IsActive=''Y'''
EXEC sp_add_jobstep
@command = @UpdateCommand,
@retry_attempts = 5,
@retry_interval = 5 ;