Reputation: 45
I have a SQL Server Agent job that consistently gets the error:
Message The job failed. The Job was invoked by Schedule 106 (Daily _ 02:30). The last step to run was step 0 (no steps ran).
I haven't been able to find anything on this error that might be causing this issue. I can run the stored procedure that is executed in the only step in the agent with no issue & this was executing properly for a while. nothing has been changed to my knowledge & this has happened with other agent jobs in the past as well. Nothing appears in the SQL Agent Error Log or the Server Log.
I've done fairly extensive web searches & haven't seen anything that has been helpful. Any assistance would be appreciated!
Upvotes: 0
Views: 77
Reputation: 45
I'm not sure why this fixing the issue and it makes no sense to me whatsoever but i set the default database back to master.
I added a USE MyDB before the stored procedure and it works now.
Use MyDB
Go
Exec MyProc
Upvotes: 0
Reputation: 1
I was having the same issue. The stored proc in itself executes but the job fails if the proc is part of job step. Finally, I managed to work around this issue by using PowerShell command in PowerShell job step:
Invoke-Sqlcmd -ServerInstance "SQLInstanceName,Port" -Database "DBName" -Query "EXEC dbo.usp_storedprocname " -AbortOnError -QueryTimeout 65535
Upvotes: 0