Print Error Message In Sql Server 2008
Contents |
Microsoft Tech Companion App Microsoft Technical Communities Microsoft Virtual Academy Script Center Server and
Sql Server Error_message
Tools Blogs TechNet Blogs TechNet Flash Newsletter TechNet Gallery sql server error_number TechNet Library TechNet Magazine TechNet Subscriptions TechNet Video TechNet Wiki Windows Sysinternals Virtual Labs t-sql @@error Solutions Networking Cloud and Datacenter Security Virtualization Downloads Updates Service Packs Security Bulletins Windows Update Trials Windows Server 2016 System Center 2016 Windows
How To Get Error Message In Sql Server Stored Procedure
10 Enterprise SQL Server 2016 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
Db2 Sql Error
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 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 Retrieving Error Information in Transact-SQL Retrieving Error Information in Transact-SQL Retrieving Error Information in Transact-SQL Retrieving Error
Microsoft Tech Companion App Microsoft Technical Communities Microsoft Virtual Academy Script Center Server and Tools Blogs TechNet Blogs TechNet Flash Newsletter error_severity() TechNet Gallery TechNet Library TechNet Magazine TechNet Subscriptions TechNet Video TechNet
Error_line()
Wiki Windows Sysinternals Virtual Labs Solutions Networking Cloud and Datacenter Security Virtualization Downloads Updates Service Packs Security error_procedure() Bulletins Windows Update Trials Windows Server 2016 System Center 2016 Windows 10 Enterprise SQL Server 2016 See all trials » Related Sites Microsoft Download Center TechNet Evaluation https://technet.microsoft.com/en-us/library/ms179495(v=sql.105).aspx 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 10 Windows Server Certification (MCSE) Private Cloud Certification (MCSE) SQL Server Certification (MCSE) Other resources TechNet Events https://technet.microsoft.com/en-us/library/ms179296(v=sql.105).aspx 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. Accessing and Changing Database Data Procedural Transact-SQL Handling Database Engine Errors Handling Database Engine Errors Using TRY...CATCH in Transact-SQL Using TRY...CATCH in Transact-SQL Using TRY...CATCH in Transact-SQL 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 TRY...CATCH in Transact-
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the http://stackoverflow.com/questions/21090076/how-to-get-error-message-from-sql-server-try-catch-block workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. sql server Join them; it only takes a minute: Sign up How to get error_message from SQL Server TRY…CATCH block [duplicate] up vote 2 down vote favorite This question already has an answer here: Using the result of an expression (e.g. Function call) in a stored procedure parameter list? 6 answers BEGIN TRY BEGIN TRANSACTION --Lots of T-SQL Code here COMMIT error message in END TRY BEGIN CATCH ROLLBACK USE [msdb]; EXEC sp_send_dbmail @profile_name='Mail Profile', @recipients='myEmail@mydomain.org', @subject='Data Error', @body = SELECT ERROR_MESSAGE(); END CATCH I am getting the following error at this line @body = SELECT ERROR_MESSAGE(); Incorrect syntax near the keyword 'SELECT'. Any one know why? sql-server tsql share|improve this question edited Jan 13 '14 at 11:48 marc_s 454k938711033 asked Jan 13 '14 at 11:24 StackTrace 3,9521858108 marked as duplicate by Martin Smith, Remus Rusanu, bytebuster, trudyscousin, vzwick Jan 13 '14 at 14:57 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. You most certainly can't have a USE [msdb]; in the middle of your CATCH block. .... –marc_s Jan 13 '14 at 11:53 add a comment| 3 Answers 3 active oldest votes up vote 4 down vote accepted You can not issue a SELECT statement directly into the parameter of a stored procedure. Do something like this instead: DECLARE @err_msg AS NVARCHAR(MAX); SET @err_msg = ERROR_MESSAGE(); EXEC sp_send_dbmail @profile_name=