Checking a SQL job status in C# using sp_help_job

2019-08-11 14:37发布

问题:

This similar question gave the solution that in order to check the status of a job in C# you must run sp_help_job. The problem is when I try the query out in SQL, I'm getting an error from SQL Server saying "Could not find stored procedure 'sp_help_job'.

I tried running this SQL code in MSS 2008:

exec sp_help_job

Can someone post the exact query to find out the status of a job I just ran?

回答1:

If you are writing C# code, the easiest solution would probably be to use the SMO API to get the information you need. You can use the Job class to get the current status and last result of a job.



回答2:

Change it to:

exec msdb.dbo.sp_help_job


回答3:

I had the same issue with running the EXEC command. However, changing the line to "exec msdb.dbo.sp_help_job" worked.