Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Storing Error Description in a Table Expand / Collapse
Author
Message
Posted Friday, December 28, 2007 3:07 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 27, 2010 9:23 AM
Points: 30, Visits: 93
Hi,

I've executed the sp and it contains more number of internal sp's. If any sp's execution failure due to some reasons, i want to store the error description into some table. Can you please help me to store the error description in some table.
Post #436962
Posted Sunday, January 6, 2008 6:21 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, September 11, 2014 10:39 AM
Points: 2,803, Visits: 3,068
What kind of error do you want to store? System error, procedure error or data error?
Post #439390
Posted Sunday, January 6, 2008 11:11 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 27, 2010 9:23 AM
Points: 30, Visits: 93
Thanks for replying.A kind of data error, I want to store it in Table. For example, if it throws some mismatch sql statements, or syntax error, it will be stored in the table
Post #439439
Posted Monday, January 7, 2008 1:11 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, September 11, 2014 10:39 AM
Points: 2,803, Visits: 3,068
I am still not very sure what you want to store because you said something about syntax error.

I had created a error table before to store the errors of some of my procedures.

CREATE TABLE Err_Table (ErrID INT IDENTITY(1,1) NOT NULL,
ProcedureName VARCHAR(250) NOT NULL,
ErrorDesc VARCHAR(250) NOT NULL,
ErrorLogTime DATETIME NOT NULL)

In the procedure that you want to capture the error, you just need to insert data into the table.

For example if the select statement has an error or it returns 0 record when you expect it should return data.

DECLARE @Error INT, @Rowcount INT

SELECT .... FROM ....

SELECT @Error = @@ERROR, @Rowcount = @@ROWCOUNT

IF @Error <> 0
INSERT INTO Err_table (ProcedureName, ErrorDesc, ErrorLogTIme) SELECT 'procedure', 'SELECT ...Statement returned error', GETDATE()

IF @Rowcount = 0

Post #439767
Posted Monday, January 7, 2008 11:43 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 27, 2010 9:23 AM
Points: 30, Visits: 93
Thanks for your reply
Post #439887
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse