@@error Sql Server 2008 Msdn
Contents |
resources Windows Server 2012 resources Programs MSDN sql server 2008 msdn download subscriptions Overview Benefits Administrators Students Microsoft Imagine
Msdn Sql Server 2008 Books Online
Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel msdn sql server 2008 tutorial 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed.
Sql Server 2008 R2 Msdn
You’ll be auto redirected in 1 second. Transact-SQL Reference (Database Engine) Built-in Functions (Transact-SQL) System Functions (Transact-SQL) System Functions (Transact-SQL) ERROR_MESSAGE (Transact-SQL) ERROR_MESSAGE (Transact-SQL) ERROR_MESSAGE (Transact-SQL) $PARTITION (Transact-SQL) @@ERROR (Transact-SQL) @@IDENTITY (Transact-SQL) @@PACK_RECEIVED (Transact-SQL) @@ROWCOUNT (Transact-SQL) @@TRANCOUNT (Transact-SQL) sql server 2008 architecture msdn BINARY_CHECKSUM (Transact-SQL) CHECKSUM (Transact-SQL) COMPRESS (Transact-SQL) CONNECTIONPROPERTY (Transact-SQL) CONTEXT_INFO (Transact-SQL) CURRENT_REQUEST_ID (Transact-SQL) CURRENT_TRANSACTION_ID (Transact-SQL) DECOMPRESS (Transact-SQL) ERROR_LINE (Transact-SQL) ERROR_MESSAGE (Transact-SQL) ERROR_NUMBER (Transact-SQL) ERROR_PROCEDURE (Transact-SQL) ERROR_SEVERITY (Transact-SQL) ERROR_STATE (Transact-SQL) FORMATMESSAGE (Transact-SQL) GET_FILESTREAM_TRANSACTION_CONTEXT (Transact-SQL) GETANSINULL (Transact-SQL) HOST_ID (Transact-SQL) HOST_NAME (Transact-SQL) ISNULL (Transact-SQL) ISNUMERIC (Transact-SQL) MIN_ACTIVE_ROWVERSION (Transact-SQL) NEWID (Transact-SQL) NEWSEQUENTIALID (Transact-SQL) ROWCOUNT_BIG (Transact-SQL) SESSION_CONTEXT (Transact-SQL) SESSION_ID (Transact-SQL) XACT_STATE (Transact-SQL) TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. ERROR_MESSAGE (Transact-SQL) Other Versions SQL Server 2012 THIS TOPIC APPLIES TO: SQL Server (starting with 2008)Azure SQL DatabaseAzure SQL Data Warehouse Parallel Data Warehouse Returns the mes
Microsoft Tech Companion App Microsoft Technical Communities Microsoft Virtual Academy Script Center Server and Tools Blogs TechNet Blogs TechNet Flash Newsletter TechNet Gallery TechNet Library TechNet Magazine
Sql Server 2005 Msdn
TechNet Subscriptions TechNet Video TechNet Wiki Windows Sysinternals Virtual Labs Solutions Networking
Sql Server 2000 Msdn
Cloud and Datacenter Security Virtualization Downloads Updates Service Packs Security Bulletins Windows Update Trials Windows Server 2012 R2 System msdn sql server express Center 2012 R2 Microsoft SQL Server 2014 SP1 Windows 8.1 Enterprise See all trials » Related Sites Microsoft Download Center TechNet Evaluation Center Drivers Windows Sysinternals TechNet Gallery Training Training https://msdn.microsoft.com/en-us/library/ms190358.aspx 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 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 https://technet.microsoft.com/en-us/library/ms190193(v=sql.105).aspx 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. Accessing and Changing Database Data Procedural Transact-SQL Handling Database Engine Errors Handling Database Engine Errors Using @@ERROR Using @@ERROR Using @@ERROR Retrieving Error Information in Transact-SQL Using TRY...CATCH in Transact-SQL Using RAISERROR Using PRINT Using @@ERROR Handling Errors and Messages in Applications TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Using @@ERROR The @@ERROR system function returns 0 if the last Transact-SQL statement executed successfully; if the statement generated an error, @@ERROR returns the error number. The value of @@ERROR changes on the completion of each Transact-SQL statement.Because @@ERROR gets a
resources Windows Server 2012 resources Programs MSDN subscriptions Overview https://msdn.microsoft.com/en-us/library/ms180031.aspx Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and https://blogs.msdn.microsoft.com/anthonybloesch/2009/03/10/sql-server-2008-error-handling-best-practice/ reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in sql server 1 second. Transact-SQL Reference (Database Engine) Built-in Functions (Transact-SQL) System Functions (Transact-SQL) System Functions (Transact-SQL) ERROR_STATE (Transact-SQL) ERROR_STATE (Transact-SQL) ERROR_STATE (Transact-SQL) $PARTITION (Transact-SQL) @@ERROR (Transact-SQL) @@IDENTITY (Transact-SQL) @@PACK_RECEIVED (Transact-SQL) @@ROWCOUNT (Transact-SQL) @@TRANCOUNT (Transact-SQL) BINARY_CHECKSUM (Transact-SQL) CHECKSUM (Transact-SQL) COMPRESS (Transact-SQL) CONNECTIONPROPERTY sql server 2008 (Transact-SQL) CONTEXT_INFO (Transact-SQL) CURRENT_REQUEST_ID (Transact-SQL) CURRENT_TRANSACTION_ID (Transact-SQL) DECOMPRESS (Transact-SQL) ERROR_LINE (Transact-SQL) ERROR_MESSAGE (Transact-SQL) ERROR_NUMBER (Transact-SQL) ERROR_PROCEDURE (Transact-SQL) ERROR_SEVERITY (Transact-SQL) ERROR_STATE (Transact-SQL) FORMATMESSAGE (Transact-SQL) GET_FILESTREAM_TRANSACTION_CONTEXT (Transact-SQL) GETANSINULL (Transact-SQL) HOST_ID (Transact-SQL) HOST_NAME (Transact-SQL) ISNULL (Transact-SQL) ISNUMERIC (Transact-SQL) MIN_ACTIVE_ROWVERSION (Transact-SQL) NEWID (Transact-SQL) NEWSEQUENTIALID (Transact-SQL) ROWCOUNT_BIG (Transact-SQL) SESSION_CONTEXT (Transact-SQL) SESSION_ID (Transact-SQL) XACT_STATE (Transact-SQL) TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. ERROR_STATE (Transact-SQL) Other Versions SQL Server 2012 THIS TOPIC APPLIES TO:SQL Server (starting with 2008)Azure SQL DatabaseAzure SQL Data Warehouse Parallel Data Warehouse Returns the state number of the error that caused the CATCH block of a TRY…CATCH construct to be run.
BloeschMarch 10, 20099 0 0 0 Error handling in SQL Server 2008 needs careful implementation. The Microsoft “Oslo” Repository’s API has the further problem that we cannot mandate the error handling logic in our callers. Thus a stored procedure call could be in a transaction or not and in a try-catch block or not. Below is the pattern we have chosen based on experimentation and best practice guidance from the SQL Server team and other SQL Server experts. A test script for all the interesting cases can be found at http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-46-95-77/Error-Handling.sql. For a good overview of SQL Server error handling see http://www.sommarskog.se/error-handling-I.html and http://www.sommarskog.se/error-handling-II.html. In our design, we had the following main issues and mitigations: · A transaction rollback will rollback to the outermost transaction but if there is an outer transaction we would like to only rollback the changes to the module’s inner transaction. The solution is to use SQL Server save points if there is an outer transaction. · A sufficiently severe raiserror will terminate a module if there is an outer try-catch block but if there is none then execution will continue in the module. The solution is to always explicitly return after raising an error. · Some developers like to use stored procedure return values to encode error states. The solution is to return appropriate error codes. · SQL Server will raise warnings if the transaction depth entering and leaving a transaction do not match. The solution is to be careful. · Triggers have an implicit transaction. The solution is to use a simplified pattern for triggers where a transaction is never started. · Save points need unique names if modules can nest otherwise you can rollback to the wrong save point. The solution is to use a GUID to name the save points. Here is the pattern for stored procedures (eliding our special error reporting routines): ifparameter errorbegin raiserror(N'…', 16, 0);
return -1;endelsebegin begin try declare @hasOuterTransaction bit