Link to home
Start Free TrialLog in
Avatar of 4Learning
4Learning

asked on

Sybase error text

How does one get a coresponding message text from @@error variable. I want to capture this in either a stored procedure or a batch file
Avatar of alpmoon
alpmoon
Flag of Australia image

I think the easiest way is just selecting description column from sysmessages table in master db:

select * from master..sysmessages where error = xxx
Avatar of 4Learning
4Learning

ASKER

Yes, but I need to write the messages to a log file in the following manner...

insert into erro_log values(@@error, error_message)

Well I dont think I can put in the select statement from sysmessages in the insert statement.

Is there another way...?

Thanks,
4learning
Sure you can.

insert into erro_log
select error, description
from master..sysmessages where error = @@error
ASKER CERTIFIED SOLUTION
Avatar of alpmoon
alpmoon
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thankyou very much alpmoon. that helps!
Why were full points awarded to alpmoon?  His solution is less efficient and is just a modification of mine.
I think what I suggested was useful because in most of the cases you need variables to check the error number later. 4Learning can combine both suggestions anyway.

However, regardless of how useful both solutions, I agree that points should be distributed when another valuable post has been submitted. It could be a suggestion or just a comment. Usually it helps to get a solution faster. I think it is late this time. But, it should be considered every time a question is closed.