Project

General

Profile

Feature #1860 » Jobs Closing BJR.sql

Tri Rizqiaty, 12/09/2022 10:18 AM

 
1
USE [msdb]
2
GO
3

    
4
/****** Object:  Job [BIA_ClosingBJR]    Script Date: 08/12/2022 17.26.32 ******/
5
BEGIN TRANSACTION
6
DECLARE @ReturnCode INT
7
SELECT @ReturnCode = 0
8
/****** Object:  JobCategory [[Uncategorized (Local)]]    Script Date: 08/12/2022 17.26.32 ******/
9
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
10
BEGIN
11
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'[Uncategorized (Local)]'
12
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
13

    
14
END
15

    
16
DECLARE @jobId BINARY(16)
17
EXEC @ReturnCode =  msdb.dbo.sp_add_job @job_name=N'BIA_ClosingBJR', 
18
		@enabled=1, 
19
		@notify_level_eventlog=0, 
20
		@notify_level_email=0, 
21
		@notify_level_netsend=0, 
22
		@notify_level_page=0, 
23
		@delete_level=0, 
24
		@description=N'BIA Perhitungan Closing BJR', 
25
		@category_name=N'[Uncategorized (Local)]', 
26
		@owner_login_name=N'sa', @job_id = @jobId OUTPUT
27
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
28
/****** Object:  Step [BIA_ClosingBJR]    Script Date: 08/12/2022 17.26.33 ******/
29
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'BIA_ClosingBJR', 
30
		@step_id=1, 
31
		@cmdexec_success_code=0, 
32
		@on_success_action=1, 
33
		@on_success_step_id=0, 
34
		@on_fail_action=2, 
35
		@on_fail_step_id=0, 
36
		@retry_attempts=0, 
37
		@retry_interval=0, 
38
		@os_run_priority=0, @subsystem=N'TSQL', 
39
		@command=N'EXECUTE CBIACLOSINGBJR', 
40
		@database_name=N'MinovaES_BIA_Dev', 
41
		@flags=0
42
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
43
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
44
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
45
EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'CLOSINGBJR', 
46
		@enabled=1, 
47
		@freq_type=4, 
48
		@freq_interval=1, 
49
		@freq_subday_type=1, 
50
		@freq_subday_interval=0, 
51
		@freq_relative_interval=0, 
52
		@freq_recurrence_factor=0, 
53
		@active_start_date=20221208, 
54
		@active_end_date=99991231, 
55
		@active_start_time=10000, 
56
		@active_end_time=235959, 
57
		@schedule_uid=N'5e9713b0-d565-4740-8ede-84c959dc9b04'
58
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
59
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
60
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
61
COMMIT TRANSACTION
62
GOTO EndSave
63
QuitWithRollback:
64
    IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
65
EndSave:
66
GO
67

    
68

    
(3-3/6)