Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Question of the month December 2011 - How will you capture multiple error messages?

Dec 14 2011 1:08AM by Madhivanan   

Assume that there is a database named test in the server and you want to take a backup of that database. Run the following code without specifying the path

backup database test to disk=''

You will get the following error messages

Msg 3044, Level 16, State 2, Line 1
Invalid zero-length device name. Reissue the BACKUP statement with a valid device name.
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.

You can however capture the error message programatically using TRY CATCH block as shown below

begin try
	backup database test to disk=''
end try
begin catch
	select  error_message() as [error_message]
end catch

But it captures only the last error message BACKUP DATABASE is terminating abnormally

How will you capture first error message too along with second error message?

Tags: tsql, SQL Server, #TSQL, #SQLServer,


Madhivanan
3 · 40% · 12899
4
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

2  Comments  

  • Hi. We can parse DBCC OUTPUTBUFFER, but personally I don't like this method. More details are here:

    http://www.sommarskog.se/error-handling-I.html#textretrieve

    Please do you know any other solution how to do it in T-SQL? I am just curious.

    Thank you a lot

    commented on Jun 1 2012 2:45PM
    Jan Novak
    448 · 0% · 88
  • You can try using the new THROW clause if you are in SQL Server 2012.

    Thanks, Manoj

    commented on Jan 24 2013 7:11AM
    Manoj
    240 · 1% · 188

Your Comment


Sign Up or Login to post a comment.

"Question of the month December 2011 - How will you capture multiple error messages?" rated 5 out of 5 by 4 readers
Question of the month December 2011 - How will you capture multiple error messages? , 5.0 out of 5 based on 4 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]