SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Storing Error Description in a Table


Storing Error Description in a Table

Author
Message
balaji_rcs
balaji_rcs
SSC-Enthusiastic
SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)

Group: General Forum Members
Points: 122 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.
Loner
Loner
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6282 Visits: 3364
What kind of error do you want to store? System error, procedure error or data error?
balaji_rcs
balaji_rcs
SSC-Enthusiastic
SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)

Group: General Forum Members
Points: 122 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
Loner
Loner
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6282 Visits: 3364
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
balaji_rcs
balaji_rcs
SSC-Enthusiastic
SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)SSC-Enthusiastic (122 reputation)

Group: General Forum Members
Points: 122 Visits: 93
Thanks for your reply
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search