<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; 2005 &#8211; Explanation of TRY&#8230;CATCH and ERROR Handling</title>
	<atom:link href="http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Saurabh Gupta</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-55430</link>
		<dc:creator>Saurabh Gupta</dc:creator>
		<pubDate>Mon, 31 Aug 2009 10:51:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-55430</guid>
		<description>Manisha
What are you trying to print? This print statement will give error. Do you want to concatenate %1 with statemetn in @SQLQUERY.
If yes then Write
PRINT &#039;%1!&#039; + @SQLQUERY
</description>
		<content:encoded><![CDATA[<p>Manisha<br />
What are you trying to print? This print statement will give error. Do you want to concatenate %1 with statemetn in @SQLQUERY.<br />
If yes then Write<br />
PRINT &#8216;%1!&#8217; + @SQLQUERY</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manisha</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-54486</link>
		<dc:creator>manisha</dc:creator>
		<pubDate>Wed, 05 Aug 2009 18:32:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-54486</guid>
		<description>Hi,

I would like to print the query I have written inside the SP while executing it so that I can debug it easily
e.g

BEGIN        
	DECLARE @SQLQUERY varchar(8000) 
	SET @SQLQUERY = &#039;select * from Roles where Role=1 &#039;  
	PRINT &#039;%1!&#039;, @SQLQUERY 
	EXEC(@SQLQUERY) 
END

I want if I execute it in sql plus it shoul give me results as well as print the query for my knowldege.

The baove syntaxt works fine with sybase but in sql server it gives me error nea comma in print statement.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I would like to print the query I have written inside the SP while executing it so that I can debug it easily<br />
e.g</p>
<p>BEGIN<br />
	DECLARE @SQLQUERY varchar(8000)<br />
	SET @SQLQUERY = &#8217;select * from Roles where Role=1 &#8216;<br />
	PRINT &#8216;%1!&#8217;, @SQLQUERY<br />
	EXEC(@SQLQUERY)<br />
END</p>
<p>I want if I execute it in sql plus it shoul give me results as well as print the query for my knowldege.</p>
<p>The baove syntaxt works fine with sybase but in sql server it gives me error nea comma in print statement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reddy</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-51015</link>
		<dc:creator>Reddy</dc:creator>
		<pubDate>Wed, 15 Apr 2009 12:36:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-51015</guid>
		<description>Imran

Thanks for your quick reply.

yes i am using linked server. I implemented sqlmail on my local server and i am getting mails. 
As i mplemented Try Catch in my trigger and we know that not all the errors will be cathed in the catch block. so better i implement the the way you suggested.

How do we check that remote server is online or not, is there any code snippet you have

part1: if (condition to check if remote server database is    online)
begin
perform what ever your action you want to perform.
end

part2: else
begin
xp_sendemail……
end

I am okay with the 2nd part and what should i write for part1? is there any system stored procedure to do that in sql2k5 as i am using sql2k5. Reply will be appreciated.

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Imran</p>
<p>Thanks for your quick reply.</p>
<p>yes i am using linked server. I implemented sqlmail on my local server and i am getting mails.<br />
As i mplemented Try Catch in my trigger and we know that not all the errors will be cathed in the catch block. so better i implement the the way you suggested.</p>
<p>How do we check that remote server is online or not, is there any code snippet you have</p>
<p>part1: if (condition to check if remote server database is    online)<br />
begin<br />
perform what ever your action you want to perform.<br />
end</p>
<p>part2: else<br />
begin<br />
xp_sendemail……<br />
end</p>
<p>I am okay with the 2nd part and what should i write for part1? is there any system stored procedure to do that in sql2k5 as i am using sql2k5. Reply will be appreciated.</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: VKP</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-51013</link>
		<dc:creator>VKP</dc:creator>
		<pubDate>Wed, 15 Apr 2009 10:57:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-51013</guid>
		<description>Nice one....</description>
		<content:encoded><![CDATA[<p>Nice one&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-50999</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Wed, 15 Apr 2009 02:14:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-50999</guid>
		<description>@Reddy, 

Instead of waiting for trigger to execute SQL statement on remote sql server (which is offline) and fail and then send an email... why don&#039;t you simple check if remote server or remote database is online. If it is online perform action, if it not online, then send email. something like this. 

Inside trigger you can add a check like this,

if  (condition to check if remote server database is online)
begin 
perform what ever your action you want to perform.
end

else 
begin
xp_sendemail......
end

This will definitely not rollback your transaction. 

If you need more help let me know. Also provide details if you are using linked server to connect to remote server. 

~ IM.</description>
		<content:encoded><![CDATA[<p>@Reddy, </p>
<p>Instead of waiting for trigger to execute SQL statement on remote sql server (which is offline) and fail and then send an email&#8230; why don&#8217;t you simple check if remote server or remote database is online. If it is online perform action, if it not online, then send email. something like this. </p>
<p>Inside trigger you can add a check like this,</p>
<p>if  (condition to check if remote server database is online)<br />
begin<br />
perform what ever your action you want to perform.<br />
end</p>
<p>else<br />
begin<br />
xp_sendemail&#8230;&#8230;<br />
end</p>
<p>This will definitely not rollback your transaction. </p>
<p>If you need more help let me know. Also provide details if you are using linked server to connect to remote server. </p>
<p>~ IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reddy</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-50976</link>
		<dc:creator>Reddy</dc:creator>
		<pubDate>Tue, 14 Apr 2009 14:46:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-50976</guid>
		<description>Hi All,

I have a situation in my Trigger.
My trigger is for update on a Table, whenever there is an update it has to fire the trigger and place the data in 2 Servers one is local and another is Remote server. what i need is sometimes my remote server goes offline, thogh the trigger firing and and i am missing some data. what i want is if is there any problem with servers or DB still it has to fire the trigger and it should notify me with a mail that there was a problem with remote server or DB, but still it has to do all the tasks it is suppose to do. so implemented try catch bolck in catch block i wrote like this

END TRY

Begin Catch
SELECT @intErrorCode = @@ERROR
    IF (@intErrorCode  0) GOTO PROBLEM

End Catch	

PROBLEM:
IF (@intErrorCode  0) 
BEGIN
declare @body1 varchar(100)
set @body1 = &#039;Server :&#039;+@@servername+ &#039;Error Message:&#039;+ERROR_MESSAGE()
EXEC msdb.dbo.sp_send_dbmail @recipients=&#039;mailid&#039;,
    @subject = &#039;My Mail Test&#039;,
    @body = @body1,
    @body_format = &#039;HTML&#039; ;
END

while i am trying get some exception trigger is not getting fired i have to rollback my operation.
Is there anyway i canget fired my trigger though there is an exception but notifying me with a mail. Any Help....</description>
		<content:encoded><![CDATA[<p>Hi All,</p>
<p>I have a situation in my Trigger.<br />
My trigger is for update on a Table, whenever there is an update it has to fire the trigger and place the data in 2 Servers one is local and another is Remote server. what i need is sometimes my remote server goes offline, thogh the trigger firing and and i am missing some data. what i want is if is there any problem with servers or DB still it has to fire the trigger and it should notify me with a mail that there was a problem with remote server or DB, but still it has to do all the tasks it is suppose to do. so implemented try catch bolck in catch block i wrote like this</p>
<p>END TRY</p>
<p>Begin Catch<br />
SELECT @intErrorCode = @@ERROR<br />
    IF (@intErrorCode  0) GOTO PROBLEM</p>
<p>End Catch	</p>
<p>PROBLEM:<br />
IF (@intErrorCode  0)<br />
BEGIN<br />
declare @body1 varchar(100)<br />
set @body1 = &#8216;Server :&#8217;+@@servername+ &#8216;Error Message:&#8217;+ERROR_MESSAGE()<br />
EXEC msdb.dbo.sp_send_dbmail @recipients=&#8217;mailid&#8217;,<br />
    @subject = &#8216;My Mail Test&#8217;,<br />
    @body = @body1,<br />
    @body_format = &#8216;HTML&#8217; ;<br />
END</p>
<p>while i am trying get some exception trigger is not getting fired i have to rollback my operation.<br />
Is there anyway i canget fired my trigger though there is an exception but notifying me with a mail. Any Help&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tejas Shah</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-50439</link>
		<dc:creator>Tejas Shah</dc:creator>
		<pubDate>Fri, 03 Apr 2009 05:52:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-50439</guid>
		<description>Hi Perez,

That is not an issue with Select. this issue with &quot;WHERE&quot;.

You can write the query as follows:

SELECT tic.cod_record_poliza,tic.cod_ramo
FROM tISO_Claim tic
WHERE cod_record_poliza = &#039;99&#039;

Let me know if it helps you.

Thanks,

Tejas</description>
		<content:encoded><![CDATA[<p>Hi Perez,</p>
<p>That is not an issue with Select. this issue with &#8220;WHERE&#8221;.</p>
<p>You can write the query as follows:</p>
<p>SELECT tic.cod_record_poliza,tic.cod_ramo<br />
FROM tISO_Claim tic<br />
WHERE cod_record_poliza = &#8216;99&#8242;</p>
<p>Let me know if it helps you.</p>
<p>Thanks,</p>
<p>Tejas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miguel Perez</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-50428</link>
		<dc:creator>Miguel Perez</dc:creator>
		<pubDate>Thu, 02 Apr 2009 19:15:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-50428</guid>
		<description>I have a problem in SQL 2000 server because I need something like try .. catch.

The problem is.

SELECT tic.cod_record_poliza,tic.cod_ramo
FROM tISO_Claim tic
WHERE cod_record_poliza = 99

Error:
Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value &#039;UP01&#039; to a column of data type int.

Note: This error is in a select statement because the column name cod_record_poliza is varchar and in this case the values is 99 instead of &#039;99&#039;. 

---&gt;&gt;&gt; I need to detect this error. &lt;&lt;&lt;&lt;-------
The question is: How could I resolve this error?</description>
		<content:encoded><![CDATA[<p>I have a problem in SQL 2000 server because I need something like try .. catch.</p>
<p>The problem is.</p>
<p>SELECT tic.cod_record_poliza,tic.cod_ramo<br />
FROM tISO_Claim tic<br />
WHERE cod_record_poliza = 99</p>
<p>Error:<br />
Server: Msg 245, Level 16, State 1, Line 1<br />
Syntax error converting the varchar value &#8216;UP01&#8242; to a column of data type int.</p>
<p>Note: This error is in a select statement because the column name cod_record_poliza is varchar and in this case the values is 99 instead of &#8216;99&#8242;. </p>
<p>&#8212;&gt;&gt;&gt; I need to detect this error. &lt;&lt;&lt;&lt;&#8212;&#8212;-<br />
The question is: How could I resolve this error?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-50220</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Mon, 30 Mar 2009 16:24:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-50220</guid>
		<description>Hi,

 If I try to drop a constraint which does not exist in the database by using the below command I get the error message

Msg 3728, Level 16, State 1, Line 1
&#039;FK_ReferencedWorkspace_SchemaVersion1&#039; is not a constraint.
Msg 3727, Level 16, State 0, Line 1
Could not drop constraint. See previous errors.

However if I have the same code enclosed within a try .. catch block with the statement 

	select  ERROR_NUMBER() as ErrorNumber,
			ERROR_LINE() AS ErrorLine,
			ERROR_MESSAGE() as ErrorMessage

  it only returns me the second error as

 &quot;Could not drop constraint. See previous errors.&quot;

How do I get the full error message so that I can trobleshoot easily OR is this a limitation of SQL Server 2005

Thanks
Ryan</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p> If I try to drop a constraint which does not exist in the database by using the below command I get the error message</p>
<p>Msg 3728, Level 16, State 1, Line 1<br />
&#8216;FK_ReferencedWorkspace_SchemaVersion1&#8242; is not a constraint.<br />
Msg 3727, Level 16, State 0, Line 1<br />
Could not drop constraint. See previous errors.</p>
<p>However if I have the same code enclosed within a try .. catch block with the statement </p>
<p>	select  ERROR_NUMBER() as ErrorNumber,<br />
			ERROR_LINE() AS ErrorLine,<br />
			ERROR_MESSAGE() as ErrorMessage</p>
<p>  it only returns me the second error as</p>
<p> &#8220;Could not drop constraint. See previous errors.&#8221;</p>
<p>How do I get the full error message so that I can trobleshoot easily OR is this a limitation of SQL Server 2005</p>
<p>Thanks<br />
Ryan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-47193</link>
		<dc:creator>SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Tue, 24 Feb 2009 12:07:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-47193</guid>
		<description>[...] SQL SERVER - 2005 Explanation of TRY…CATCH and ERROR Handling [...]</description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; 2005 Explanation of TRY…CATCH and ERROR Handling [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamleshkumar Gujarathi.</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-46958</link>
		<dc:creator>Kamleshkumar Gujarathi.</dc:creator>
		<pubDate>Fri, 20 Feb 2009 11:13:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-46958</guid>
		<description>I am trying to write the exception details in the text file.

What will be the faster way ? 

Kamleshkumar Gujarathi.</description>
		<content:encoded><![CDATA[<p>I am trying to write the exception details in the text file.</p>
<p>What will be the faster way ? </p>
<p>Kamleshkumar Gujarathi.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ARUP</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-46313</link>
		<dc:creator>ARUP</dc:creator>
		<pubDate>Wed, 04 Feb 2009 08:08:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-46313</guid>
		<description>Hi,

I want to use try-catch block against any user defined condition. say I am ising an IF block to satisfy some conditions . If it will dissatisfy, then I want to go to CATCH block. Is it possible?

BEGIN TRY
       IF (@variable between 1 AND 8) --condition as per client emand) --
             error produced
END TRY

BEGIN CATCH
       
END CATCH</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I want to use try-catch block against any user defined condition. say I am ising an IF block to satisfy some conditions . If it will dissatisfy, then I want to go to CATCH block. Is it possible?</p>
<p>BEGIN TRY<br />
       IF (@variable between 1 AND 8) &#8211;condition as per client emand) &#8211;<br />
             error produced<br />
END TRY</p>
<p>BEGIN CATCH</p>
<p>END CATCH</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karthik</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-44859</link>
		<dc:creator>Karthik</dc:creator>
		<pubDate>Tue, 16 Dec 2008 19:24:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-44859</guid>
		<description>Hi,

I want to use 2 try blocks in same stored proc. If the FIRST try block fails it goes to catch..suppose.. if my SECOND block fails, whether the first TRY block transaction gets rolledback or not?
this is my scenario
// success
begin tran
begin try

insert1
insert2
insert3
end try

begin catch
rollback
end catch

end try
commit tran
//failure
begin tran
begin try

insert1
insert2
insert3
end try

begin catch
rollback
end catch

end try
commit tran</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I want to use 2 try blocks in same stored proc. If the FIRST try block fails it goes to catch..suppose.. if my SECOND block fails, whether the first TRY block transaction gets rolledback or not?<br />
this is my scenario<br />
// success<br />
begin tran<br />
begin try</p>
<p>insert1<br />
insert2<br />
insert3<br />
end try</p>
<p>begin catch<br />
rollback<br />
end catch</p>
<p>end try<br />
commit tran<br />
//failure<br />
begin tran<br />
begin try</p>
<p>insert1<br />
insert2<br />
insert3<br />
end try</p>
<p>begin catch<br />
rollback<br />
end catch</p>
<p>end try<br />
commit tran</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anand</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-43686</link>
		<dc:creator>Anand</dc:creator>
		<pubDate>Tue, 14 Oct 2008 08:27:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-43686</guid>
		<description>your article was extremely useful for my sql dba telephonic interview. I need answers for few questions where i was not sure.

1. How will you detect that a deadlock occured in SQL server 2000 and how will you resolve it ?
2.How many stored procedures can be written in a single crystal report?</description>
		<content:encoded><![CDATA[<p>your article was extremely useful for my sql dba telephonic interview. I need answers for few questions where i was not sure.</p>
<p>1. How will you detect that a deadlock occured in SQL server 2000 and how will you resolve it ?<br />
2.How many stored procedures can be written in a single crystal report?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruchi Saini</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-42629</link>
		<dc:creator>Ruchi Saini</dc:creator>
		<pubDate>Wed, 10 Sep 2008 06:56:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-42629</guid>
		<description>Hi,

Is Try catch block is an alternative of @@raiseerror that we used in SQL 2000.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Is Try catch block is an alternative of @@raiseerror that we used in SQL 2000.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farhad</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-39167</link>
		<dc:creator>Farhad</dc:creator>
		<pubDate>Wed, 11 Jun 2008 23:02:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-39167</guid>
		<description>Can we use BEGIN CATCH etc.. in a trigger?</description>
		<content:encoded><![CDATA[<p>Can we use BEGIN CATCH etc.. in a trigger?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nisheeth</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-21859</link>
		<dc:creator>Nisheeth</dc:creator>
		<pubDate>Thu, 22 Nov 2007 07:26:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-21859</guid>
		<description>Nice work man keep it up..

Nisheeth Pandya</description>
		<content:encoded><![CDATA[<p>Nice work man keep it up..</p>
<p>Nisheeth Pandya</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - 2005 - Explanation of TRY…CATCH and ERROR Handling With RAISEERROR Function Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-14689</link>
		<dc:creator>SQL SERVER - 2005 - Explanation of TRY…CATCH and ERROR Handling With RAISEERROR Function Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Wed, 03 Oct 2007 14:28:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-14689</guid>
		<description>[...] function in new feature of SQL Server 2005 TRY&#8230;CATCH. When asked for explanation he suggested SQL SERVER - 2005 Explanation of TRY…CATCH and ERROR Handling article as excuse suggesting that I did not give example of RAISEERROR with TRY&#8230;CATCH. We all [...]</description>
		<content:encoded><![CDATA[<p>[...] function in new feature of SQL Server 2005 TRY&#8230;CATCH. When asked for explanation he suggested SQL SERVER &#8211; 2005 Explanation of TRY…CATCH and ERROR Handling article as excuse suggesting that I did not give example of RAISEERROR with TRY&#8230;CATCH. We all [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russell</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-12258</link>
		<dc:creator>Russell</dc:creator>
		<pubDate>Wed, 12 Sep 2007 16:50:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-12258</guid>
		<description>This is a catch block that I created that takes care of a cursor called &quot;file_cursor&quot;. probably could be a little more robust, but it does the trick:

BEGIN CATCH
	DECLARE @ErrorMessage NVARCHAR(4000);

	IF @@TRANCOUNT &gt; 0
	BEGIN
        ROLLBACK TRANSACTION;
		PRINT &#039;TRANSACTION ABORTED&#039;
	END

	PRINT CURSOR_STATUS(&#039;global&#039;, &#039;file_cursor&#039;)

	IF CURSOR_STATUS(&#039;global&#039;,&#039;file_cursor&#039;) &gt; 0
	BEGIN
		CLOSE file_cursor
		DEALLOCATE file_cursor
		PRINT &#039;The cursor has been closed and deallocated&#039;
	END

    DECLARE @ErrorSeverity INT;
    DECLARE @ErrorState INT;

    SELECT 
        @ErrorMessage = ERROR_MESSAGE(),
        @ErrorSeverity = ERROR_SEVERITY(),
        @ErrorState = ERROR_STATE();

	IF @ErrorState &lt; 1 
		SET @ErrorState = 1
		
    -- Use RAISERROR inside the CATCH block to return error
    -- information about the original error that caused
    -- execution to jump to the CATCH block.
	--SET @ErrorMessage = &#039;Procedure BLAH: &#039; + @ErrorMessage
    RAISERROR (@ErrorMessage, -- Message text.
               @ErrorSeverity, -- Severity.
               @ErrorState -- State.
               );
END CATCH</description>
		<content:encoded><![CDATA[<p>This is a catch block that I created that takes care of a cursor called &#8220;file_cursor&#8221;. probably could be a little more robust, but it does the trick:</p>
<p>BEGIN CATCH<br />
	DECLARE @ErrorMessage NVARCHAR(4000);</p>
<p>	IF @@TRANCOUNT &gt; 0<br />
	BEGIN<br />
        ROLLBACK TRANSACTION;<br />
		PRINT &#8216;TRANSACTION ABORTED&#8217;<br />
	END</p>
<p>	PRINT CURSOR_STATUS(&#8216;global&#8217;, &#8216;file_cursor&#8217;)</p>
<p>	IF CURSOR_STATUS(&#8216;global&#8217;,'file_cursor&#8217;) &gt; 0<br />
	BEGIN<br />
		CLOSE file_cursor<br />
		DEALLOCATE file_cursor<br />
		PRINT &#8216;The cursor has been closed and deallocated&#8217;<br />
	END</p>
<p>    DECLARE @ErrorSeverity INT;<br />
    DECLARE @ErrorState INT;</p>
<p>    SELECT<br />
        @ErrorMessage = ERROR_MESSAGE(),<br />
        @ErrorSeverity = ERROR_SEVERITY(),<br />
        @ErrorState = ERROR_STATE();</p>
<p>	IF @ErrorState &lt; 1<br />
		SET @ErrorState = 1</p>
<p>    &#8212; Use RAISERROR inside the CATCH block to return error<br />
    &#8212; information about the original error that caused<br />
    &#8212; execution to jump to the CATCH block.<br />
	&#8211;SET @ErrorMessage = &#8216;Procedure BLAH: &#8216; + @ErrorMessage<br />
    RAISERROR (@ErrorMessage, &#8212; Message text.<br />
               @ErrorSeverity, &#8212; Severity.<br />
               @ErrorState &#8212; State.<br />
               );<br />
END CATCH</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Atul</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-7313</link>
		<dc:creator>Atul</dc:creator>
		<pubDate>Fri, 10 Aug 2007 18:20:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/#comment-7313</guid>
		<description>Hi All,

You Can use the Cursor_Status() function to check the status of the cursor in the CATCH Block and write the code accordingly 

For full detail go to bookonline topic 
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/3a4a840e-04f8-43bd-aada-35d78c3cb6b0.htm</description>
		<content:encoded><![CDATA[<p>Hi All,</p>
<p>You Can use the Cursor_Status() function to check the status of the cursor in the CATCH Block and write the code accordingly </p>
<p>For full detail go to bookonline topic<br />
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/3a4a840e-04f8-43bd-aada-35d78c3cb6b0.htm</p>
]]></content:encoded>
	</item>
</channel>
</rss>
