Mssql 2000 Error
Contents |
Recent PostsRecent Posts Popular TopicsPopular Topics Home Search Members Calendar Who's On Home » Article Discussions » Article Discussions by Author »
Sql Error Handling Best Practices
Discuss content posted by Mudassar Ahmed Khan... » Get Error Description in SQL Server error handling sql server 2000 15 posts,Page 1 of 212»» Get Error Description in SQL Server 2000 Rate Topic Display Mode Topic Options Author
Tsql @@error Message
Message Mudassar Ahmed KhanMudassar Ahmed Khan Posted Monday, January 12, 2009 9:45 PM Forum Newbie Group: General Forum Members Last Login: Monday, December 9, 2013 2:25 AM Points: 8, Visits: 36 Comments posted sql server 2000 error handling to this topic are about the item Get Error Description in SQL Server 2000 Post #635145 philcartphilcart Posted Monday, January 12, 2009 9:52 PM SSCrazy Group: General Forum Members Last Login: Yesterday @ 2:34 PM Points: 2,709, Visits: 1,421 Looks pretty familiar.http://www.sqlservercentral.com/articles/Stored+Procedures/capturingtheerrordescriptioninastoredprocedure/1342/ Hope this helpsPhill Carter--------------------Colt 45 - the original point and click interface Australian SQL Server User Groups-My profilePhills PhilosophiesMurrumbeena Cricket Club Post #635146 Mudassar Ahmed KhanMudassar error handling in sql server 2012 Ahmed Khan Posted Monday, January 12, 2009 10:19 PM Forum Newbie Group: General Forum Members Last Login: Monday, December 9, 2013 2:25 AM Points: 8, Visits: 36 Yes I had a look. It is similar to mine. But I have not extracted any thing from it. If I had done so why would I post the article on same site.:) Post #635151 Mark D PowellMark D Powell Posted Tuesday, January 13, 2009 10:42 AM SSCommitted Group: General Forum Members Last Login: Wednesday, September 7, 2016 11:25 AM Points: 1,615, Visits: 449 I was unable to find sp_GetErrorDesc in the resouce section. Where should (url) I be looking? A search on the procedure name returned no hits.-- Mark -- Post #635644 Mudassar Ahmed KhanMudassar Ahmed Khan Posted Tuesday, January 13, 2009 10:59 AM Forum Newbie Group: General Forum Members Last Login: Monday, December 9, 2013 2:25 AM Points: 8, Visits: 36 Its there in the Resources Section There's a link to download the file The File Name itself is the link Text sp_GetErrorDesc.sql Search for this sp_GetErrorDesc.sql Post #635663 Mudassar Ahmed KhanMudassar Ahmed Khan Posted Tuesday, January 13, 2009 11:01 AM Forum Newbie Group: General Forum Members Last Login: Monday, D
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn
Tsql Iserror
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags t sql error_number Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you,
Set Xact_abort
helping each other. Join them; it only takes a minute: Sign up Proper use of @@Error in SQL Server 2000 up vote 2 down vote favorite Taking any example for SQL Server 2000 documentation, or something like http://www.sqlservercentral.com/Forums/Topic635145-1456-1.aspx Use Northwind Go Alter Procedure spu_UpdateOrderDetails( @ProductID Int, @OrderId Int, @ErrorCode Int OutPut, @ErrorMessage Varchar(100) Output ) As UPDATE [Order Details] SET ProductID = @ProductID WHERE OrderID = @OrderId Set @ErrorCode = @@ERROR IF @ErrorCode <> 0 Set @ErrorMessage = 'Some error ocurred' GO Declare @MyErrorCode Int Declare @MyErrorMsg Varchar(100) Exec spu_UpdateOrderDetails 999, 10248, @MyErrorCode OutPut, @MyErrorMsg OutPut Print @MyErrorCode Print @MyErrorMsg This will cause a Foreign Key error, and I wll print the @MyErrorMsg properly. http://stackoverflow.com/questions/10858472/proper-use-of-error-in-sql-server-2000 But I still get the ugly Foreign Key error. Now, if I run from within my application, it could be Delphi or Visual Studio, I still get the ugly error message, too. How am I supposed to "trap" an error, so that I show my custom error to the user? (I know newer SQL Server versions provides Try/Catch, but this is SQL Server 2000) sql-server sql-server-2000 share|improve this question asked Jun 1 '12 at 23:17 Craig Stevensson 60111133 2 Read the Bible on SQL Server 2000 error handling and see if it helps: sommarskog.se/error-handling-I.html#whathappens –mellamokb Jun 1 '12 at 23:21 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote Put it in a transaction, and roll it back it if errors, commit if success: SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE PROCEDURE spu_UpdateOrderDetails AS DECLARE @ErrorCode int --,@myRowCount int ,@ProductID ,@OrderId --,@ErrorMessage Varchar(100) Output SET NOCOUNT ON BEGIN TRAN UPDATE [Order Details] SET ProductID = @ProductID WHERE OrderID = @OrderId SELECT @ErrorCode = @@ERROR--, @myRowCount = @@ROWCOUNT IF @ErrorCode != 0 GOTO HANDLE_ERROR COMMIT TRAN -- No Errors, so go ahead RETURN 0 HANDLE_ERROR: ROLLBACK TRAN RETURN @ErrorCode GO share|improve this answer answered Jun 2 '12 at 16:52 user1166147 1,2942917 I'm sorry, but that still returns the ugly Foreign Key error to the client. I think