Job Step Getting Igonred While Execution Of The Job ?
Mar 2, 2008Hi pals,
I have stored procedure which creates job with 3 job steps whichruns 3 SSIS packages in a sequence.
But i dont know why it is skipping the 2nd step and executing the 3rd step.
I can clearly observe it in the logs.
And if comment the 3rd step and re-run the job, now it is executing the 1st and 2nd step in a sequence.
I can see the log for 2nd package also.
Again i uncommented the code for calling the 3rd step which loads data into Oracle tables.
This time again it is skipping the 2nd step.
I dont know the reason why it is happening so.
It is really frustrating me a lot.
IS there any precedence/ priority given while loading data into Oracle database?
Job steps
First step loads data from staging database to ODS
Second step loads data from ODS to DataMart
Third step loads data from DataMart to Oracle Tables
Can anyone please help me out.
I have tried all options.
Here is my stored procedure.
Is anything wrong in the below stored procedure.
CREATE PROCEDURE [dbo].[spExecDTSPackage]
as
declare @jid uniqueidentifier
declare @cmd1 varchar(4000)
declare @cmd2 varchar(4000)
declare @cmd3 varchar(4000)
SET @cmd1 = '"C:Program FilesMicrosoft SQL Server90DTSBinnDTExec.exe" /F "D:RepositoryPackage1.dtsx" '
SET @cmd2 = '"C:Program FilesMicrosoft SQL Server90DTSBinnDTExec.exe" /F "D:RepositoryPackage2.dtsx" '
SET @cmd3 = '"C:Program FilesMicrosoft SQL Server90DTSBinnDTExec.exe" /F "D:RepositoryPackage3.dtsx" '
declare @jname varchar(128)
set @jname = cast(newid() as char(36))
exec msdb.dbo.sp_add_job
@job_name = @jname,
@enabled = 1,
@delete_level = 1,
@job_id = @jid OUTPUT
exec msdb.dbo.sp_add_jobserver
@job_id = @jid,
@server_name = '(local)'
exec msdb.dbo.sp_add_jobstep
@job_id = @jid,
@step_name = N'step1',
@step_id = 1,
@on_success_action=4,
@on_success_step_id=2,
@subsystem = N'CMDEXEC',
@proxy_name = N'Proxyname',
@command = @cmd1,
@on_fail_action = 2 -- quit with failure
exec msdb.dbo.sp_add_jobstep
@job_id = @jid,
@step_name = N'step2',
@step_id = 2,
@on_success_action=4,
@on_success_step_id=3,
@subsystem = N'CMDEXEC',
@proxy_name = N'Proxyname',
@command = @cmd2
exec msdb.dbo.sp_add_jobstep
@job_id = @jid,
@step_name = N'CoreD_To_Oracle',
@step_id = 3,
@on_success_action=1,
@on_success_step_id=0,
@subsystem = N'CMDEXEC',
@proxy_name = N'Proxyname',
@command = @cmd3
-- Start job
exec msdb.dbo.sp_start_job
@job_id = @jid,
@step_name = N'step1'
I have also tried out with an simple example , a job with 3 steps which basically inserts 3 recs into a table.
Here is the code and this one is executing fine.
USE [msdb]
GO
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
DECLARE @jobId BINARY(16)
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'2D4474C9-2B4F-45C2-8640-EB8DE30A5276',
@enabled=1,
@notify_level_eventlog=2,
@notify_level_email=0,
@notify_level_netsend=0,
@notify_level_page=0,
@delete_level=1,
@description=N'No description available.',
@category_name=N'SRM',
@owner_login_name=N'sa',
@job_id = @jobId OUTPUT
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'Step_1',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=4,
@on_success_step_id=2,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0,
@subsystem=N'TSQL',
@command=N'use ods
go
insert into test select 1,''ram''
go',
@database_name=N'master',
@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'Step_2',
@step_id=2,
@cmdexec_success_code=0,
@on_success_action=4,
@on_success_step_id=3,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0,
@subsystem=N'TSQL',
@command=N'use ods
go
insert into test select 2, ''ganesh''
go',
@database_name=N'master',
@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0)
GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId,
@step_name=N'Step_3',
@step_id=3,
@cmdexec_success_code=0,
@on_success_action=1,
@on_success_step_id=0,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0,
@subsystem=N'TSQL',
@command=N'use ods
go
insert into test select 3,''Vinod''
go',
@database_name=N'master',
@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0)
GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId,
@start_step_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0)
GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
IF (@@ERROR <> 0 OR @ReturnCode <> 0)
GOTO QuitWithRollback
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:
I dont know why the stored procedure is not working as expected.
Any thoughts?
Welch can you please help on this regard?