Checking a SQL job status in C# using sp_help_job

泄露秘密 提交于 2020-01-16 04:40:10

问题


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.



来源:https://stackoverflow.com/questions/8170438/checking-a-sql-job-status-in-c-sharp-using-sp-help-job

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!