Friday, March 9, 2012

Job execution logged as an error

I have a special necessity in which I need that the result of failed jobs in
SQL Server Agent be logged as errors in Windows Event Viewer.
Normally they are logged as Warnings.
We developed a solution that uses active scripting for writing the errors in
Event Viewer. However, the policy configured prevents the execution of active
scripting.
Is there any other way of writing the result of failed jobs as errors in
Event Viewer?
I was hoping that there was a configuration that could be done to change the
type of event written in Event Viewer.
ThanksMaybe something using a job step of raiserror with log as a
failure branch in the job might work for you.
-Sue
On Tue, 03 Oct 2006 15:51:32 GMT, "jaimefelipe" <u27450@.uwe>
wrote:
>I have a special necessity in which I need that the result of failed jobs in
>SQL Server Agent be logged as errors in Windows Event Viewer.
>Normally they are logged as Warnings.
>We developed a solution that uses active scripting for writing the errors in
>Event Viewer. However, the policy configured prevents the execution of active
>scripting.
>Is there any other way of writing the result of failed jobs as errors in
>Event Viewer?
>I was hoping that there was a configuration that could be done to change the
>type of event written in Event Viewer.
>Thanks|||Thanks for your reply Sue.
I tried the command sugested but, in order to run it, the job has to be
configured as sysadmin and this is not allowed in my company.
Is there other way?
Sue Hoegemeier wrote:
>Maybe something using a job step of raiserror with log as a
>failure branch in the job might work for you.
>-Sue
>>I have a special necessity in which I need that the result of failed jobs in
>>SQL Server Agent be logged as errors in Windows Event Viewer.
>[quoted text clipped - 12 lines]
>>Thanks|||xp_logevent?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"jaimefelipe" <u27450@.uwe> wrote in message news:673a0cf792feb@.uwe...
> Thanks for your reply Sue.
> I tried the command sugested but, in order to run it, the job has to be
> configured as sysadmin and this is not allowed in my company.
> Is there other way?
>
> Sue Hoegemeier wrote:
>>Maybe something using a job step of raiserror with log as a
>>failure branch in the job might work for you.
>>-Sue
>>I have a special necessity in which I need that the result of failed jobs in
>>SQL Server Agent be logged as errors in Windows Event Viewer.
>>[quoted text clipped - 12 lines]
>>Thanks
>|||Tibor Karaszi wrote:
>xp_logevent?
>> Thanks for your reply Sue.
>[quoted text clipped - 13 lines]
>>Thanks
I order to run it, the user also has to be sysyadmin or db_owner of the
master database and there is a policy in my company that does not allow it.
So that does not solve my problem yet, but thanks.|||> I order to run it, the user also has to be sysyadmin or db_owner
Did you try it? Below executes just fine on my 2005 installation:
CREATE LOGIN x WITH PASSWORD = 'y'
CREATE USER x
GRANT EXECUTE ON xp_logevent TO x
EXECUTE AS LOGIN = 'X'
GO
EXEC xp_logevent 50001, 'My error', 'ERROR'
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"jaimefelipe" <u27450@.uwe> wrote in message news:673aaf26ce58d@.uwe...
> Tibor Karaszi wrote:
>>xp_logevent?
>> Thanks for your reply Sue.
>>[quoted text clipped - 13 lines]
>>Thanks
>
> I order to run it, the user also has to be sysyadmin or db_owner of the
> master database and there is a policy in my company that does not allow it.
> So that does not solve my problem yet, but thanks.
>

No comments:

Post a Comment