473,379 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

SQL errors, trapping in Server Agent

Hello to all,

I've fallow problem. I've a sp called as a job of SA each minute. This
runs pretty nice, but from time to time, the job is aborted, and I
don't know why.

Considering my logging, which is implemented in DB, I know, in which
point it is happening, but I don't know the exact error.
This one is for sure any SQL server exception.

I wanted to track this error, but reading all news, and help, and
performing some tests, I've find out, that this is almost like
impossible, to catch the error in t-sql code (for example in this sp),
and wirte it to any table for futher review.
Reading great documentation from Erland Sommarskog, I know, there is
no way to catch this error in t-sql, because, usualy the sql terminates
execution of the code immieadetly (so I found it also by my tests).

Now, my question is: sice I'm calling this sp continously in Server
Agent as a job scheduled to be called each one minute, is it any way,
to trap this error on this level? In SA? and THEN save it somewhere in
my db?

I'm calling the sp as a 'command' in job step as 'exec
sp_name_of_procedure'.
If I'll try like this:

declare @err int
set @err = 0

exec sp_name_of_procedure
set @err = @@error
if @err <> 0
begin
insert into tbl_logger (sql_error, msg) values (@err, 'SQL raised an
error')
end

will it work, or the sql will assume the whole code as a one batch, and
will terminate after call of sp?

Thank you in advance for reply.

Greatings

Mateusz

Nov 28 '05 #1
2 1405
Matik (ma****@sauron.xo.pl) writes:
I've fallow problem. I've a sp called as a job of SA each minute. This
runs pretty nice, but from time to time, the job is aborted, and I
don't know why.


When you view job history, there is a check box to include the step
details. This is usually where the error message is hiding.

You can also define an output file for the step.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Nov 28 '05 #2
Thank you Erland,

As usual great reply.

Thanks.

Mateusz

Nov 29 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Paul | last post by:
I thought this is more of an IE issue but i've had no joy on that group perhaps somebody here will have a clue. If i click a link to a web page embedded in Excel (97 OR 2000) i get the standard...
12
by: Russ | last post by:
Hello. My new dev machine is running XP Pro. In the past all equipment has only used Windows 2000. I have had a lot of problems getting my projects up and running on the new machine. The current...
21
by: Neil | last post by:
Is there a way to trap an error generated in another app that is controlled via automation? I have an Access 2000 app that opens Word 2000 and proceeds to open a series of documents and, in each...
1
by: Ersin Gençtürk | last post by:
We couldn't find why these errors happen.They doesn't appear everytime.And they appear different pages at different times.Is there somebody know why these happenes ? First user gets this error :...
4
by: Praveen_db2 | last post by:
Hi All I am getting strange errors in my db2diag.log can any one tell me what these errors mean?? Following is the code from my db2diag.log...
42
by: smerf | last post by:
Using javascript, is there a way to trap an external page inside a frame? I've seen scripts to break out of frames, but nothing to keep a page trapped in a frame.
0
by: AndreasJ.Mueller | last post by:
Hi Since we have moved our application (.NET 1.1) to a new server a few weeks ago we have seen in the event-logs multiple errors (which in itself is not my current problem, so I no...
9
by: ARC | last post by:
Hello all, I've noticed some funny things in my 2007 app lately, particularly where it's not putting up errors when I know a field doesn't exist, etc. In the VBA window, under Tools, Options,...
8
by: rjlorenzo | last post by:
Good Day Everyone, Requesting for your expertise please, in my program the user has to enter the agent name and the from date and to date inorder to display the record. I have to use 2 conditions....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.