how to record both success and fail in SQL Server Agent Job - sql

I am using SQL Server 2008 and I am writing a SQL Server Agent Job. In my Job, there are 3 steps and in each step I will execute a store procedure. I noticed that in default Notification setting, it write information to Windows event log only when it fails.
My question is, any easy solutions to write both success and fail information of each step to windows event log or somewhere to easily monitored? My job runs daily and I need the information for both success and fail to ensure my job runs.
thanks in advance,
George

The Notifications in the job properties also allows you to pick an action when the job succeeds! That button to the right is a dropdown, really - you can pick various outcomes, e.g. write to event log when it fails, and send an e-mail when it succeeds.
If you choose the "If job completes" option, I believe the action (write to event log, send e-mail etc.) will be triggered in both cases - success and failure.
Marc
PS: maybe this here helps?
http://msdn.microsoft.com/en-us/library/ms191130.aspx
If you want to notify an operator by e-mail, check E-mail, select an operator from the list, and then select one of the following:
* When the job succeeds to notify the operator when the job completes successfully.
* When the job fails to notify the operator when the job completes unsuccessfully.
* When the job completes to notify the operator regardless of completion status.

Related

How to log the SQL Job failure to the Log Table?

SQL Jobs are running from the SQL Agent. At this moment, we don't have the Email Notification configured for failure from the SQL Job.
I am considering to fetch the errors from the log table. Further then to have a stored procedure to generate the error report.
select top 10 * from msdb.dbo.sysjobhistory
How to log the SQL Job failure to the Log Table? What will happen, when a job is scheduled to run for every 5 mins and the error will get updated (or) error will get inserted as new record?
Follow these steps:
Open Properties of job
Go under Steps
Get into the step by pressing Edit button
Navigate under Advanced
Change the on Failure Action to Quit the job reporting failure
Then Check Log To table
I ran into the limitations of the built-in logs, job history, etc., where it doesn't capture when a step fails, but the job itself doesn't.
Based upon this sqlshack article, I built and implemented something very similar which maintains a permanent history of job/step failures, etc., even if you delete a job/step. This solution will even notify when this job fails.
Best of luck!

When I start My SAP MMC EC6 server one service is not getting to wait mode

Can someone of you help me, how to make the following service selected in the image get into wait mode after starting the server.
Please let me know if developer trace is required to be posted for resolving this issue.
that particular process is a BATCH process, a process that runs scheduled background tasks (maintained by transaction SM36/SM37). If the process is busy right after starting the server, that means there were scheduled tasks with status released waiting for execution, and as soon as the server was up, it started those tasks.
If you want to make sure the system doesn't immediately start released background tasks, you'll have to set the status back to scheduled (which, thanks to a bit of weird translation, means they won't be executed because they are not released).
if you want to start the server without having a chance to first change the job status in SM37, you would either have to reset the status on database level (likely not officially supported by SAP) or first start the server without any BATCH processes (which would give you a number of great big warning messages upon login) and change the job status before then restarting the server with the BATCH processes. You can set the number of processes for each type in the profile of your instance (parameter rdisp/wp_no_btc).

SSIS Agent job keeps running as "inprogress"

I have a SSIS package that monitors a folder. This package will run continuously until it's terminated.
I want to schedule this using a SQL Agent job.This SQL Agent job will utilize two steps. It is kind of heart beat job to to make sure the SSIS package runs.
Step - 1 it checks whether the SSIS package is running. if running quit else step 2.
Step - 2 Execute the SSIS job. if OK then report success and quit else report failure and quit.
uses a daily schedule Mon-Fri every 4 hrs.
When I execute the SQL Job, it starts the SSIS package but the job keeps running and the job monitor and history shows it as "inprogress"
I had to close the job to come out of the dialog but in background the SSIS job is still running as expected.
Is this normal behavior ? Do I need to approach this in a different way ?
Appreciate any pointers or help on this.
Once the job has begun, the Start Jobs dialog box has no impact whatsoever on the running of the job itself - it exists solely to provide a monitoring window for you. Closing it will have no effect on the running job.
From other phrases in your question, I gather that you do not expect the job to ever 'finish' - therefore I would expect it to always show as In Progress unless it errors out or is stopped.
"This package will run continuously until it's terminated."
"The job keeps running and the job monitor and history shows it as in progress"

How to start a job or process when a job on another server finished?

I want to send a mail or automatically start a job on my server as soon as a job on another server has finished successfully. I have access to the other server and can view the job status but I cannot change the job itself, which is running an SSIS package.
Basically, I want to start refreshing my database (via running an ETL through job) as soon as source has stopped refreshing itself. I would love to have suggestion beside this windows service implementation.
I took the liberty of editing the question and title to make it more explicit. As I understand it from your description, you want to run a job (or start some other process) on server A when a job on server B has completed successfully. You cannot change the job definition on server B, but you can log on to it and view the job history.
If you can't change the job or anything else on server B, that means it cannot notify server A when the job is complete. Therefore, you need to query server B from server A, using a Windows service or possibly a simple script that runs every few minutes (or hours, or whatever is appropriate).
You can query the status of a job from .NET or PowerShell using the SMO Job class, or from TSQL using the sp_help_job procedure. Which of these is a better solution depends on how you want to implement your polling mechanism.

SQL Server Agent Job is not running

I have a job that is supposed to run every 11 AM and 8 PM. About two weeks ago, it started to not respect the schedule. The "fix" that I found was to start the job manually and then the job would restart respecting the schedule for a while but eventually the issue reappears.
The big problem is that there are no error message what so ever. If the job fails, I am supposed to get a notification Email which I do not. In the sql server agent logs and the Job history, there are no errors. In the job history, I can see clearly that the job skipped the schedule since there are no entries. It looks like it did not even start as if the running time had not arrived.
The schedule is set to run everyday and there are no limits on how long it is supposed to run. The sql Agent is set to restart automatically if it stops unexpectedly.
Did anyone get this problem before?
Check the user which is used to run the job. Maybe the user password is expired or the user itself is no longer active.