I am creating sql server 2008 Agent scheduler job form sql script. Want to Log the details if failed in some case within Job 开发者_开发知识库> View Histroy.
Is there any way, so we can log custom text with Job > View Histroy?
The simplest way is to use the print command in your SQL script
i.e.
Print "Script Started"
-- Do something interesting
Print "Script Finished"
Then look at the individual step to see the output. The only problem is that it will look something like this:
Message
Executed as user: NT AUTHORITY\NETWORK SERVICE. Script Started [SQLSTATE 01000] (Message 0) Script Finished [SQLSTATE 01000] (Message 0). The step succeeded.
Which is a bit awkward to extract.
精彩评论