代码之家  ›  专栏  ›  技术社区  ›  Ab Bennett

在中添加我自己的命令行时不会记住SSIS作业步骤

  •  0
  • Ab Bennett  · 技术社区  · 6 年前

    我的工作是什么。我已经通过SSMS gui和这些脚本输入了这个。如果取消对默认命令行文本的注释,并使用单词BUG添加my own,则不会记住它。

    我试过这几种方法,读过我能找到的,但没有成功。谢谢

    BEGIN TRANSACTION
    DECLARE @ReturnCode INT
    SELECT @ReturnCode = 0
    
    IF EXISTS (SELECT job_id FROM msdb.dbo.sysjobs_view WHERE name = N'Poo')
       EXEC sp_delete_job @job_name = N'Poo'
    
    DECLARE @jobId BINARY(16)
    EXEC @ReturnCode =  msdb.dbo.sp_add_job @job_name=N'Poo', 
            @enabled=1, 
            @notify_level_eventlog=0, 
            @notify_level_email=0, 
            @notify_level_netsend=0, 
            @notify_level_page=0, 
            @delete_level=0, 
            @description=N'No description available.', 
            @category_name=N'[Uncategorized (Local)]', 
            @owner_login_name=N'XXX', @job_id = @jobId OUTPUT
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    /****** Object:  Step [main]    Script Date: 7/01/2019 2:43:21 PM ******/
    EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'main', 
            @step_id=1, 
            @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'SSIS', 
    
            /* problem here */
    
            @command=N'/FILE "\"\\xxxx\0_Startup.dtsx\""  /CHECKPOINTING OFF /REPORTING E', 
    
    
    
            --@command=N'BUG', /* uncomment and comment above to demo */
            @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_jobschedule @job_id=@jobId, @name=N'X', 
            @enabled=1, 
            @freq_type=4, 
            @freq_interval=1, 
            @freq_subday_type=1, 
            @freq_subday_interval=0, 
            @freq_relative_interval=0, 
            @freq_recurrence_factor=0, 
            @active_start_date=20190107, 
            @active_end_date=99991231, 
            @active_start_time=180000, 
            @active_end_time=235959, 
            @schedule_uid=N'5a413d73-5bda-4567-a90e-e7341f06a6d1'
    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:
    GO
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Ab Bennett    6 年前

    结果是配置被正确地存储了,是SSMS错误缠身,无法显示它。

    验证

    select * from dbo.sysjobsteps