SQL Server Maintenance Plan Not working - no errors - sql

To put it simply. I have a SQL Server maintenance plan scheduled to run every Sunday at 8:02 am. This morning when I checked the jobs it says it was successful but it didn't actually run (yesterday on 5/20) it is still showing the successful message from the previous run on 5/13. The job is enabled and I cant find any errors associated with it in the logs. A bit stumped.

Related

How to kill a SQL Server job which keeps on showing an "In Progress" status?

I am using SQL Server 2014 and I have a job (let's call it JN5) scheduled to run at a specific time on a daily basis. The job runs an SSIS package and has 11 steps in it. Looking at the Job History in SSMS, the job seems to be stuck at Step 9. It is not showing as a failure but "In Progress".
I am having a hard time trying to stop it. I have tried the following:
USE msdb ;
GO
EXEC dbo.sp_stop_job N'JN5' ;
GO
I get the following error after execution:
Msg 22022, Level 16, State 1, Line 2
SQLServerAgent Error: Request to stop job JN5 (from User sa) refused because the job is not currently running.
Then, I tried the following: I restarted the SQL Server Agent through SQL Server Configuration Manager. When I viewed the SQL Job Status (after a Refresh) in SSMS, it was still showing "In Progress" !
My next attempt to solve the issue was to restart SQL Server 2014. I then checked the status again in SSMS. It was still showing the "In Progress" status!
I just had a look at the following on StackOverflow: SQL Server job activity (job failed but history records in job activity still showing 'running' status)
However, I am not sure if the above link relates to my problem.
Any ideas on what I can attempt next?
I encountered a similar issue recently. I had a job running, scheduled via SQL Server Agent Jobs, executing from the SSISDB Catalog. (ie a scheduled SSIS job).
During the job, one of the steps processes an SSIS task which used a connection manager to a file (a sql script). While this was running, someone applied some patches to the server and restarted the SQL services stack.
This resulted in the job looking like it was processing (via job history) and appeared to be running (via Integration Services dashboard)... but there was no longer any IO (and none of the SQL in the script had completed execution)...so I knew it was relatively safe to kill the job.
I got the same error:
Msg 22022, Level 16, State 1, Line 9 SQLServerAgent Error: Request to stop job XXXXX (from User YYYYY) refused because the job is not currently running.
So I referenced the ID of the operation from the Integration Services Dashboard, and issues the following commands:
USE SSISDB
GO
EXEC [catalog].[stop_operation] <OperationId>
This removed the running job from the Integration Services dashboard.
When I had this problem I could only solve it by deleting the job.
Before, I created the script to recreate the job. So I only lost the job history.

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!

SQL Error log Time Gap

The question is more towards the possible causes why SQL error log stops logging. In my scenario, checked the System/Applications logs for any crash or service stopped events and it was all clear.
The last timestamp in the log was 8:53 Am and it straight away jumps to 6:50 PM, close to 9hrs of gap with no information. And Database connectivity issue with the application as reported starts around 2:40 PM.Snippet
Security patches were applied the previous day and the server was rebooted at 6:20 AM.
Ultimately, SQL services were restarted to regain connectivity.
I suspect the patch but Anyone has any idea how and why would SQL server stop logging?
So i have the same issue, the last log i have is from Saturday then nothing till we restarted it on Monday.
we also applied "updated with the Windows Update to SQL Server 2016 SP1 Cumulative Update (CU) 8 KB4077064"on Saturday
the last error i have is
"An error occurred while trying to flush all running Extended Event sessions. Some events may be lost."

What would cause SQL Server to stop writing to the error log?

Error logs for our SQL Server instance are gathering a large amount of data (250k records in a month) all day, then all of a sudden stop at roughly the same time of day (9:15pm), though on different days of the week and at seemingly random intervals of days.
This corresponds to other issues on the server: 1) jobs that move files to shares on the database server fail 2) I am not able to access the server via any method (tried RDP and SSMS). Once the servers are rebooted, SQL Server comes up and SQL Server error logging resumes.
Windows Event Viewer doesn't show any notable error messages for System (the other event logs have wrapped already).
The error logs are being written to the D:\ drive, which has over 100GB free currently. The error log files are in the range of tens of megabytes.
Appreciate any ideas on what might have caused this or how troubleshoot it. Thanks!
The cause appears to have been a corrupted maintenance plan. I discovered this by correlating the timing of the lock-up to the times the maintenance plan was running. The lack of logging made this difficult to confirm. Guessing that at least some parts of it ran normally, but got rolled back on restart.
The current fix was to disable the maintenance plan and replace it with a collection of jobs that do the same tasks. I will likely recreate the original maintenance plan if the server remains stable for another week or two. If we stay stable past that point, it should solidly confirm the maintenance plan as the source of the problem.

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.