sql-agent

SQL Server Agent Jobs Log custom messages in Job History

荒凉一梦 提交于 2019-12-01 09:56:00
问题 Is it possible to log custom messages from your SQL Server Agent job in the job history messages? If not what's the best way to go about doing such a thing? 回答1: For T-SQL job steps, you can use the print statement. For CmdExec steps, use Console.Writeline in your executable. If there is a lot of output, then by default SQL Agent will not keep all of, and will only keep a certain number of characters. To have it keep all output for a step, you go to the step properties, Advanced, and check

Increase TEXT SIZE in SQL Server Agent

99封情书 提交于 2019-12-01 05:46:18
问题 SQL Server Agent has a 512 characters limit on texts fields like nvarchar(max). I found this out after seeing my stored procedure is working correctly when I run it in SSMS but not working when is being run by a SQL Server job. To fix this I know I can use SET TEXTSIZE { number } in my stored procedure to increase this number. However I don't want to add this line in each and every stored procedure that are being run by SQL Server jobs. Is there a way that I can set this value for SQL Server

how to know status of currently running jobs

大城市里の小女人 提交于 2019-11-28 19:30:09
问题 I need to know if a given Job is currently running on Ms SQL 2008 server. So as to not to invoke same job again that may lead to concurrency issues. 回答1: It looks like you can use msdb.dbo.sysjobactivity , checking for a record with a non-null start_execution_date and a null stop_execution_date, meaning the job was started, but has not yet completed. This would give you currently running jobs: SELECT sj.name , sja.* FROM msdb.dbo.sysjobactivity AS sja INNER JOIN msdb.dbo.sysjobs AS sj ON sja