Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display @@ERROR

Status
Not open for further replies.

chillay

Programmer
Jun 27, 2002
102
US
Hello there

Given the following:

------------------

BEGIN TRANSACTION

INSERT INTO ServicePlans (PlanID, PlanName,
PlanDescription, PlanPrice, DiscountedPrice)
VALUES ('C1001', 'Tele-Training Course',
'Course on Telecommunications', 45.00, 35.00)

SAVE TRANSACTION Insert1

INSERT INTO Orders (CustomerID, PlanID,
OrderDate, CancelationDate)
VALUES (10, 'C1001', '11/27/01', NULL)

IF @@ERROR <> 0 ROLLBACK TRANSACTION Insert1

COMMIT TRANSACTION

-------------------

I'd like to display the return for @@Error when running the query. How can this be done?

Also, is @@error logical/boolean? (would "If @@ERROR ..." be the same as "If @@ERROR <> 0")?

Thank you in advance.

Chillay
 
@@Error returns an Integer value, the number of the error. This number corresponds to the number in master..sysmessages table. You would need to look in that table for the error returned, and display the message.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top