<?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; Tips from the SQL Joes 2 Pros Development Series &#8211; Structured Error Handling &#8211; Day 28 of 35</title>
	<atom:link href="http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER &#8211; Expanding Views &#8211; Contest Win Joes 2 Pros Combo (USD 198) &#8211; Day 4 of 5 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-327439</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Expanding Views &#8211; Contest Win Joes 2 Pros Combo (USD 198) &#8211; Day 4 of 5 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Thu, 09 Aug 2012 01:31:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-327439</guid>
		<description><![CDATA[[...] SQL Joes 2 Pros Development Series – Structured Error Handling [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL Joes 2 Pros Development Series – Structured Error Handling [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ram</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-168352</link>
		<dc:creator><![CDATA[Ram]]></dc:creator>
		<pubDate>Thu, 15 Sep 2011 11:55:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-168352</guid>
		<description><![CDATA[Option 4 as delete statement tends to catch block where rollback will undo all actions done in transaction and too in nested transactions.

This is Ram from India]]></description>
		<content:encoded><![CDATA[<p>Option 4 as delete statement tends to catch block where rollback will undo all actions done in transaction and too in nested transactions.</p>
<p>This is Ram from India</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER – Programming and Development – Book Available for SQL Server Certification Journey to SQLAuthority</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-165513</link>
		<dc:creator><![CDATA[SQL SERVER – Programming and Development – Book Available for SQL Server Certification Journey to SQLAuthority]]></dc:creator>
		<pubDate>Mon, 05 Sep 2011 01:31:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-165513</guid>
		<description><![CDATA[[...] Q 28) SQL SERVER – Tips from the SQL Joes 2 Pros Development Series – Structured Error Handling – Da... [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Q 28) SQL SERVER – Tips from the SQL Joes 2 Pros Development Series – Structured Error Handling – Da&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163932</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Wed, 31 Aug 2011 12:07:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163932</guid>
		<description><![CDATA[&lt;p style=&quot;text-align:justify;&quot;&gt;1) The product will not be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.
&lt;/p&gt;
&lt;p style=&quot;text-align:justify;&quot;&gt;Winner from USA: &lt;b&gt;&lt;a href=&quot;http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162757&quot; rel=&quot;nofollow&quot;&gt;Apnesh&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p style=&quot;text-align:justify;&quot;&gt;Winner from India: &lt;b&gt;&lt;a href=&quot;http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162766&quot; rel=&quot;nofollow&quot;&gt;shatrughna kumar&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;


I thank you all for participating here. The permanent record of this update is posted on &lt;a href=&quot;http://www.facebook.com/SQLAuth?sk=app_179191362131547&quot; rel=&quot;nofollow&quot;&gt;facebook&lt;/a&gt; page.]]></description>
		<content:encoded><![CDATA[<p style="text-align:justify;">1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.
</p>
<p style="text-align:justify;">Winner from USA: <b><a href="http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162757" rel="nofollow">Apnesh</a></b></p>
<p style="text-align:justify;">Winner from India: <b><a href="http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162766" rel="nofollow">shatrughna kumar</a></b></p>
<p>I thank you all for participating here. The permanent record of this update is posted on <a href="http://www.facebook.com/SQLAuth?sk=app_179191362131547" rel="nofollow">facebook</a> page.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vaishali jain</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163574</link>
		<dc:creator><![CDATA[vaishali jain]]></dc:creator>
		<pubDate>Tue, 30 Aug 2011 10:22:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163574</guid>
		<description><![CDATA[Option 4 is the correct answer

Vaishali Jain
Hyderabad
India]]></description>
		<content:encoded><![CDATA[<p>Option 4 is the correct answer</p>
<p>Vaishali Jain<br />
Hyderabad<br />
India</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Nelson</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163283</link>
		<dc:creator><![CDATA[Matt Nelson]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 17:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163283</guid>
		<description><![CDATA[The answer is 4.

From Books Online (http://msdn.microsoft.com/en-us/library/ms175976.aspx)
If an error generated in a TRY block causes the state of the current transaction to be invalidated, the transaction is classified as an uncommittable transaction..........When a batch finishes, the Database Engine rolls back any active uncommittable transactions.

Matt Nelson, USA]]></description>
		<content:encoded><![CDATA[<p>The answer is 4.</p>
<p>From Books Online (<a href="http://msdn.microsoft.com/en-us/library/ms175976.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms175976.aspx</a>)<br />
If an error generated in a TRY block causes the state of the current transaction to be invalidated, the transaction is classified as an uncommittable transaction&#8230;&#8230;&#8230;.When a batch finishes, the Database Engine rolls back any active uncommittable transactions.</p>
<p>Matt Nelson, USA</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Seefeld</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163242</link>
		<dc:creator><![CDATA[David Seefeld]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 13:57:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163242</guid>
		<description><![CDATA[The correct option is #4

1) The product will not be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.

Because the TRY statement would generate the error, the CATCH would be executed instead.  The code from the TRY block would never run.  If any statement raises a level 11 or higher severity in the Try Block, it will not show the error from the calling code. It will run the code you have set up in the Catch Block.

Country of residence: USA]]></description>
		<content:encoded><![CDATA[<p>The correct option is #4</p>
<p>1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.</p>
<p>Because the TRY statement would generate the error, the CATCH would be executed instead.  The code from the TRY block would never run.  If any statement raises a level 11 or higher severity in the Try Block, it will not show the error from the calling code. It will run the code you have set up in the Catch Block.</p>
<p>Country of residence: USA</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vinay (@vinayprasadv)</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163229</link>
		<dc:creator><![CDATA[vinay (@vinayprasadv)]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 13:36:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163229</guid>
		<description><![CDATA[Answer is:

4.1) The product will not be deleted from the CurrentProducts table.
   2) The order details will not be inserted into the SalesInvoiceHeader table.

Vinay,
Pune, India.]]></description>
		<content:encoded><![CDATA[<p>Answer is:</p>
<p>4.1) The product will not be deleted from the CurrentProducts table.<br />
   2) The order details will not be inserted into the SalesInvoiceHeader table.</p>
<p>Vinay,<br />
Pune, India.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sachin kulshreshtha</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163191</link>
		<dc:creator><![CDATA[sachin kulshreshtha]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 11:30:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163191</guid>
		<description><![CDATA[Ans : 4
1) The product will not be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.

Noida, INDIA]]></description>
		<content:encoded><![CDATA[<p>Ans : 4<br />
1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.</p>
<p>Noida, INDIA</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ritesh Choksi</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163152</link>
		<dc:creator><![CDATA[Ritesh Choksi]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 08:56:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163152</guid>
		<description><![CDATA[correct answer is option 4
India]]></description>
		<content:encoded><![CDATA[<p>correct answer is option 4<br />
India</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kulshresth Bhardwaj</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163130</link>
		<dc:creator><![CDATA[Kulshresth Bhardwaj]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 06:58:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163130</guid>
		<description><![CDATA[Kulshresth Bhardwaj
Correct Option is 4

4.
1) The product will not be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.

Country : India


The product will not be deleted from the CurrentProducts table as it will violate the foreign key constraint . As ProductID is the foreign key in SalesInvoiceHeader Table and it references the ProductID of the CurrentProduct  table where it acts as a primary key. and we are trying to delete the value of a column ProductID (CurrentProducts ) of which ProductID (SalesInvoiceHeader table) depends.]]></description>
		<content:encoded><![CDATA[<p>Kulshresth Bhardwaj<br />
Correct Option is 4</p>
<p>4.<br />
1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.</p>
<p>Country : India</p>
<p>The product will not be deleted from the CurrentProducts table as it will violate the foreign key constraint . As ProductID is the foreign key in SalesInvoiceHeader Table and it references the ProductID of the CurrentProduct  table where it acts as a primary key. and we are trying to delete the value of a column ProductID (CurrentProducts ) of which ProductID (SalesInvoiceHeader table) depends.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sudeepta</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163128</link>
		<dc:creator><![CDATA[sudeepta]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 06:49:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163128</guid>
		<description><![CDATA[The correct answer is :
4.1) The product will not be deleted from the CurrentProducts table.
   2) The order details will not be inserted into the SalesInvoiceHeader table.

Sudeepta,
India.]]></description>
		<content:encoded><![CDATA[<p>The correct answer is :<br />
4.1) The product will not be deleted from the CurrentProducts table.<br />
   2) The order details will not be inserted into the SalesInvoiceHeader table.</p>
<p>Sudeepta,<br />
India.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163123</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 06:31:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163123</guid>
		<description><![CDATA[Answer is option 4

4.
1) The product will not be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.

Country : India]]></description>
		<content:encoded><![CDATA[<p>Answer is option 4</p>
<p>4.<br />
1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.</p>
<p>Country : India</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rahul Dewada</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163114</link>
		<dc:creator><![CDATA[Rahul Dewada]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 06:03:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163114</guid>
		<description><![CDATA[The Correct option is 
#4. 

Country : India]]></description>
		<content:encoded><![CDATA[<p>The Correct option is<br />
#4. </p>
<p>Country : India</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Azhar Iqbal</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163092</link>
		<dc:creator><![CDATA[Azhar Iqbal]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 04:37:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163092</guid>
		<description><![CDATA[Correct Option 4.
Because If error occure in inner transaction then outer transactions would also be rolled back.

Azhar Iqbal
From Lahore Pakistan.]]></description>
		<content:encoded><![CDATA[<p>Correct Option 4.<br />
Because If error occure in inner transaction then outer transactions would also be rolled back.</p>
<p>Azhar Iqbal<br />
From Lahore Pakistan.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sunil (India)</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163091</link>
		<dc:creator><![CDATA[Sunil (India)]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 04:33:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163091</guid>
		<description><![CDATA[Answer is Option # 4]]></description>
		<content:encoded><![CDATA[<p>Answer is Option # 4</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sravan</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163078</link>
		<dc:creator><![CDATA[sravan]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 03:56:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163078</guid>
		<description><![CDATA[Correct Option is 4

I&#039; from INDIA]]></description>
		<content:encoded><![CDATA[<p>Correct Option is 4</p>
<p>I&#8217; from INDIA</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: prideofrohan</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-163022</link>
		<dc:creator><![CDATA[prideofrohan]]></dc:creator>
		<pubDate>Sun, 28 Aug 2011 23:39:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-163022</guid>
		<description><![CDATA[Question 28: Answer is option 4. 

First of all, you cannot insert a foreign key when it&#039;s primary key does not exist. This violates integrity constraints. 
Second, since there is an exception, the commit does not occur.

Thanks
Vijay from USA]]></description>
		<content:encoded><![CDATA[<p>Question 28: Answer is option 4. </p>
<p>First of all, you cannot insert a foreign key when it&#8217;s primary key does not exist. This violates integrity constraints.<br />
Second, since there is an exception, the commit does not occur.</p>
<p>Thanks<br />
Vijay from USA</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Basavaraj Biradar</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162972</link>
		<dc:creator><![CDATA[Basavaraj Biradar]]></dc:creator>
		<pubDate>Sun, 28 Aug 2011 18:53:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-162972</guid>
		<description><![CDATA[Correct Answer is option 4

Thanks,
Basavaraj
India]]></description>
		<content:encoded><![CDATA[<p>Correct Answer is option 4</p>
<p>Thanks,<br />
Basavaraj<br />
India</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Pepping</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162968</link>
		<dc:creator><![CDATA[Bill Pepping]]></dc:creator>
		<pubDate>Sun, 28 Aug 2011 18:27:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-162968</guid>
		<description><![CDATA[Hi Pinal,
 
Challenge:
Question 28
You have tables named CurrentProducts and SalesInvoiceHeader. The CurrentProducts table has a foreign key relationship with the SalesInvoiceHeader table on the ProductID column. You are deleting ProductID 77 from the Product table and then trying to insert a sale for Product77 into the SalesInvoiceHeader table.

BEGIN TRY
BEGIN TRANSACTION
DELETE FROM CurrentProducts  WHERE ProductID = 77
BEGIN TRANSACTION
INSERT INTO SalesInvoiceHeader VALUES ( 95894, 77, 2 )
COMMIT TRANSACTION
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
PRINT ERROR_MESSAGE()
END CATCH

What will be the outcome when you run this query?

1.1 The product will be deleted from the CurrentProducts table.
2) The order details will be inserted into the SalesInvoiceHeader table.
2.1) The product will be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.
3.1) The product will not be deleted from the CurrentProducts table.
2) The order details will be inserted into the SalesInvoiceHeader table.
4.1) The product will not be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.


Correct Answer:
The correct choice is #4:

4.1) The product will not be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.


Explanation:
The insertion of the data into the SalesInvoiceHeader table will fail because the previous transaction deleted ProductID 77 from the table.  Since the code above shows a nested transaction for the insertion of the SalesInvoiceHeader data, the error in that transaction will initiate the code in the Catch section, which will ROLLBACK both transactions, and then run the print any error messages that are generated from the ERROR_MESSAGE( ) function.

Country:
United States
 
Thanks for the knowledge!
 

Regards,

 Bill Pepping]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Challenge:<br />
Question 28<br />
You have tables named CurrentProducts and SalesInvoiceHeader. The CurrentProducts table has a foreign key relationship with the SalesInvoiceHeader table on the ProductID column. You are deleting ProductID 77 from the Product table and then trying to insert a sale for Product77 into the SalesInvoiceHeader table.</p>
<p>BEGIN TRY<br />
BEGIN TRANSACTION<br />
DELETE FROM CurrentProducts  WHERE ProductID = 77<br />
BEGIN TRANSACTION<br />
INSERT INTO SalesInvoiceHeader VALUES ( 95894, 77, 2 )<br />
COMMIT TRANSACTION<br />
COMMIT TRANSACTION<br />
END TRY<br />
BEGIN CATCH<br />
ROLLBACK TRANSACTION<br />
PRINT ERROR_MESSAGE()<br />
END CATCH</p>
<p>What will be the outcome when you run this query?</p>
<p>1.1 The product will be deleted from the CurrentProducts table.<br />
2) The order details will be inserted into the SalesInvoiceHeader table.<br />
2.1) The product will be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.<br />
3.1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will be inserted into the SalesInvoiceHeader table.<br />
4.1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.</p>
<p>Correct Answer:<br />
The correct choice is #4:</p>
<p>4.1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.</p>
<p>Explanation:<br />
The insertion of the data into the SalesInvoiceHeader table will fail because the previous transaction deleted ProductID 77 from the table.  Since the code above shows a nested transaction for the insertion of the SalesInvoiceHeader data, the error in that transaction will initiate the code in the Catch section, which will ROLLBACK both transactions, and then run the print any error messages that are generated from the ERROR_MESSAGE( ) function.</p>
<p>Country:<br />
United States</p>
<p>Thanks for the knowledge!</p>
<p>Regards,</p>
<p> Bill Pepping</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Don</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162960</link>
		<dc:creator><![CDATA[Don]]></dc:creator>
		<pubDate>Sun, 28 Aug 2011 17:52:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-162960</guid>
		<description><![CDATA[optio4 will be the result of the given SQL statement.

Country: United States]]></description>
		<content:encoded><![CDATA[<p>optio4 will be the result of the given SQL statement.</p>
<p>Country: United States</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chetan</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162959</link>
		<dc:creator><![CDATA[Chetan]]></dc:creator>
		<pubDate>Sun, 28 Aug 2011 17:51:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-162959</guid>
		<description><![CDATA[Answer is #4.

1) The product will not be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.

Before commit we will get error and hence transaction will be rolled back.

Chetan - USA]]></description>
		<content:encoded><![CDATA[<p>Answer is #4.</p>
<p>1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.</p>
<p>Before commit we will get error and hence transaction will be rolled back.</p>
<p>Chetan &#8211; USA</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajneesh Verma</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162958</link>
		<dc:creator><![CDATA[Rajneesh Verma]]></dc:creator>
		<pubDate>Sun, 28 Aug 2011 17:49:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-162958</guid>
		<description><![CDATA[The correct option is option 4

Thanks.
Rajneesh Verma
(INDIA)]]></description>
		<content:encoded><![CDATA[<p>The correct option is option 4</p>
<p>Thanks.<br />
Rajneesh Verma<br />
(INDIA)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kkmjssate</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162957</link>
		<dc:creator><![CDATA[kkmjssate]]></dc:creator>
		<pubDate>Sun, 28 Aug 2011 17:44:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-162957</guid>
		<description><![CDATA[Answer:4 is correct
1) The product will not be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.
Krishan kumar mishra]]></description>
		<content:encoded><![CDATA[<p>Answer:4 is correct<br />
1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.<br />
Krishan kumar mishra</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nikhil Mahajan</title>
		<link>http://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/#comment-162939</link>
		<dc:creator><![CDATA[Nikhil Mahajan]]></dc:creator>
		<pubDate>Sun, 28 Aug 2011 16:34:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=14104#comment-162939</guid>
		<description><![CDATA[the correct answer is option 4 i.e.



1) The product will not be deleted from the CurrentProducts table.
2) The order details will not be inserted into the SalesInvoiceHeader table.

India]]></description>
		<content:encoded><![CDATA[<p>the correct answer is option 4 i.e.</p>
<p>1) The product will not be deleted from the CurrentProducts table.<br />
2) The order details will not be inserted into the SalesInvoiceHeader table.</p>
<p>India</p>
]]></content:encoded>
	</item>
</channel>
</rss>
