multiple first day of week
-
Nice trick:
http://richardlees.blogspot.nl/2015/08/supporting-multiple-first-day-of-week.html
Tuesday, April 15, 2014
Daily change of output file name
-- Daily change of job log file
-- 20140416 John Minkjan i8Solutions
DECLARE @nSQL varchar(max)
DECLARE c cursor for
SELECT
-- [sJOB].[job_id] AS [JobID]
-- , [sJOB].[name] AS [JobName]
-- , [sJSTP].[step_uid] AS [StepID]
-- , [sJSTP].[step_id] AS [StepNo]
-- , [sJSTP].[step_name] AS [StepName]
-- , [sJSTP].[database_name] AS [Database]
'EXECUTE msdb.dbo.sp_update_jobstep
@job_id = N'''+ CAST([sJOB].[job_id] as varchar(50)) +'''
,@step_id = N''' + CAST([sJSTP].[step_id] as varchar(50)) + '''
,@output_file_name = N'''+ '\\SVRAPPL5\D$\i8log\i8_job_'+ replace([sJOB].[name],' ','_') + '_' +replace([sJSTP].[step_name],' ','_')+'_' +convert(varchar(8),getdate(),112)+'.txt''
,@flags = 2 -- append to output file '
FROM
[msdb].[dbo].[sysjobsteps] AS [sJSTP]
INNER JOIN [msdb].[dbo].[sysjobs] AS [sJOB]
ON [sJSTP].[job_id] = [sJOB].[job_id]
where [sJSTP].flags = 2 -- 2 = append to output file
OPEN C
FETCH NEXT FROM C INTO @nSQL;
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC(@nSQL);
FETCH NEXT FROM C INTO @nSQL;
END
CLOSE C
DEALLOCATE C
Till Next Time
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment