@@error In Sql Server 2000
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies sql server 2000 error message of this site About Us Learn more about Stack Overflow the company
Sql Server 2000 Raiserror
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Error In Sql Server 2005
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:
Sql Server 2000 Try Catch
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 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 sql server error 229 <> 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. 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 59611033 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
Editions: US United States Australia United Kingdom Japan Newsletters Forums Resource Library Tech Pro Free Trial Membership Membership My Profile People Subscriptions My sql server error log stuff Preferences Send a message Log Out TechRepublic Search GO Topics: sql server error 233 CXO Cloud Big Data Security Innovation Software Data Centers Networking Startups Tech & Work All Topics Sections: Photos sql server error 53 Videos All Writers Newsletters Forums Resource Library Tech Pro Free Trial Editions: US United States Australia United Kingdom Japan Membership Membership My Profile People Subscriptions My stuff Preferences Send http://stackoverflow.com/questions/10858472/proper-use-of-error-in-sql-server-2000 a message Log Out Data Management Understanding error handling in SQL Server 2000 Transaction design and error handling in SQL Server 2000 is no easy task. Tim Chapman provides insight into designing transactions and offers a few tips to help you develop custom error handling routines for your applications. By Tim Chapman | June 5, 2006, 12:00 AM http://www.techrepublic.com/article/understanding-error-handling-in-sql-server-2000/ PST RSS Comments Facebook Linkedin Twitter More Email Print Reddit Delicious Digg Pinterest Stumbleupon Google Plus Most iterative language compilers have built-in error handling routines (e.g., TRY…CATCH statements) that developers can leverage when designing their code. Although SQL Server 2000 developers don't enjoy the luxury that iterative language developers do when it comes to built-in tools, they can use the @@ERROR system variable to design their own effective error-handling tools. Introducing transactions In order to grasp how error handling works in SQL Server 2000, you must first understand the concept of a database transaction. In database terms, a transaction is a series of statements that occur as a single unit of work. To illustrate, suppose you have three statements that you need to execute. The transaction can be designed in such a way so that all three statements occur successfully, or none of them occur at all. When data manipulation operations are performed in SQL Server, the operation takes place in buffer memory and not immediately to the physical table. Later, wh
Microsoft Tech Companion App Microsoft Technical Communities Microsoft Virtual Academy Script Center Server and Tools Blogs TechNet Blogs https://technet.microsoft.com/en-us/library/aa175920(v=sql.80).aspx TechNet Flash Newsletter TechNet Gallery TechNet Library TechNet Magazine TechNet Subscriptions TechNet Video TechNet Wiki Windows Sysinternals Virtual Labs Solutions Networking Cloud and Datacenter Security Virtualization Downloads Updates Service Packs Security Bulletins Windows Update Trials Windows Server 2012 R2 System Center 2012 R2 Microsoft SQL Server 2014 SP1 Windows 8.1 sql server Enterprise See all trials » Related Sites Microsoft Download Center TechNet Evaluation Center Drivers Windows Sysinternals TechNet Gallery Training Training Expert-led, virtual classes Training Catalog Class Locator Microsoft Virtual Academy Free Windows Server 2012 courses Free Windows 8 courses SQL Server training Microsoft Official Courses On-Demand Certifications Certification overview MCSA: Windows sql server 2000 10 Windows Server Certification (MCSE) Private Cloud Certification (MCSE) SQL Server Certification (MCSE) Other resources TechNet Events Second shot for certification Born To Learn blog Find technical communities in your area Support Support options For business For developers For IT professionals For technical support Support offerings More support Microsoft Premier Online TechNet Forums MSDN Forums Security Bulletins & Advisories Not an IT pro? Microsoft Customer Support Microsoft Community Forums United States (English) Sign in Home Library Wiki Learn Gallery Downloads Support Forums Blogs We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Periodicals Microsoft SQL Server Professional June 2000 June 2000 Error Handling in T-SQL: From Casual to Religious Error Handling in T-SQL: From Casual to Religious Error Handling in T-SQL: From Casual to Religious Error Handling in T-SQL: From Casual to Religious TOC Collapse the table of content Expand the table of co