Изменить владельца mssql job

USE msdb ;
GO
 
EXEC dbo.sp_manage_jobs_by_login
    @action = N'REASSIGN',
    @current_owner_login_name = N'HEAD_OFFICE\v.musalov',
    @new_owner_login_name = N'sa' ;
GO
SELECT  [job_id]
      ,[originating_server_id]
      ,[name]
      ,[enabled]
      ,[description]
      ,[start_step_id]
      ,[category_id]
      ,[owner_sid]
      ,[notify_level_eventlog]
      ,[notify_level_email]
      ,[notify_level_netsend]
      ,[notify_level_page]
      ,[notify_email_operator_id]
      ,[notify_netsend_operator_id]
      ,[notify_page_operator_id]
      ,[delete_level]
      ,[date_created]
      ,[date_modified]
      ,[version_number]
  FROM [msdb].[dbo].[sysjobs]
 
 
  select * from [msdb].[dbo].[sysjobs]
 
  SELECT [job_id]
      ,[step_id]
      ,[step_name]
      ,[subsystem]
      ,command
      ,replace([command],'ssas_molniya','diablo')
      ,[flags]
      ,[additional_parameters]
      ,[cmdexec_success_code]
      ,[on_success_action]
      ,[on_success_step_id]
      ,[on_fail_action]
      ,[on_fail_step_id]
      ,[server]
      ,[database_name]
      ,[database_user_name]
      ,[retry_attempts]
      ,[retry_interval]
      ,[os_run_priority]
      ,[output_file_name]
      ,[last_run_outcome]
      ,[last_run_duration]
      ,[last_run_retries]
      ,[last_run_date]
      ,[last_run_time]
      ,[proxy_id]
      ,[step_uid]
  FROM [msdb].[dbo].[sysjobsteps]
  where database_name = 'ssas_molniya' 
  --and command like '%ssas_molniya%' 
  and job_id in (
      select job_id
  FROM [msdb].[dbo].[sysjobs] where date_created > '20140713'
  )
 
 
  update [msdb].[dbo].[sysjobsteps]
  set database_name = 'ssas_molniya_sz'
  where database_name = 'ssas_molniya'
  and job_id in (
      select job_id
  FROM [msdb].[dbo].[sysjobs] where date_created > '20140713'
  )
GO

 

Similar Posts:

Метки:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *