﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Discuss content posted by ~~Hari.Bagra / Article Discussions by Author  / DDL Rollback / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 03:40:12 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>E@sy</description><pubDate>Tue, 13 Oct 2009 05:24:10 GMT</pubDate><dc:creator>BudaCli</dc:creator></item><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>[quote][b]Richard Sisk (10/5/2009)[/b][hr]Huh, what?!  I got the following when I tested my answer...(1 row(s) affected)Msg 208, Level 16, State 1, Line 2Invalid object name 'T'.Where did I go wrong in my life...[/quote]I got the same thing when I ran this code:[code]CREATE TABLE T ( ID int NOT NULL, Code varchar(10) NULL)INSERT INTO T SELECT 1,'AAAA' GOBEGIN Tran t1 DROP TABLE T ROLLBACK Tran GOSELECT * FROM T[/code]But when I moved the "GO" in the ROLLBACK Tran GO to the next line and ran it as this:[code] CREATE TABLE T ( ID int NOT NULL, Code varchar(10) NULL)INSERT INTO T SELECT 1,'AAAA' GOBEGIN Tran t1 DROP TABLE T ROLLBACK Tran GOSELECT * FROM T[/code] it ran just fine with the expected response.  SQL was probably looking at the GO as the alias for Tran and that was messing things up as there was no GO transaction.  At least, that's what I think is the reason behind why it didn't work the first time.</description><pubDate>Tue, 06 Oct 2009 12:10:03 GMT</pubDate><dc:creator>Kit G</dc:creator></item><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>[quote][b]Hari.Sharma (10/6/2009)[/b][hr][quote][b]ramonaraujop (10/5/2009)[/b][hr]to do rollback in a right way,I wrote:-----------------BEGIN Tran t1 DROP TABLE TgoROLLBACK GO----------------SELECT * FROM Tthe Question of the Day was wrong, I guess, so, was completed with errors. The transaction was used before cross the word "go" so, [/quote]I dont know why you are putting GO in between a transaction. As far as my understanding is concern, a transaction can't be splitted in two batches as you are doing by using GO.Now come to the second point where you mentioned it a wrong question, but the question is all about DDL Rollback... Since it is mentioned in BOL that DDL statements cannot be rolled back then why the Table exists?[/quote]The following is directly from the referenced link in the answer to this question:[quote]Many types of operations are recorded in the transaction log, including: The start and end of each transaction.Every data modification (insert, update, or delete). This includes changes to system tables made by system stored procedures or data definition language (DDL) statements.Every extent allocation or deallocation.The creation or dropping of a table or index. [/quote]</description><pubDate>Tue, 06 Oct 2009 06:24:53 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>[quote][b]ramonaraujop (10/5/2009)[/b][hr]to do rollback in a right way,I wrote:-----------------BEGIN Tran t1 DROP TABLE TgoROLLBACK GO----------------SELECT * FROM Tthe Question of the Day was wrong, I guess, so, was completed with errors. The transaction was used before cross the word "go" so, [/quote]I dont know why you are putting GO in between a transaction. As far as my understanding is concern, a transaction can't be splitted in two batches as you are doing by using GO.Now come to the second point where you mentioned it a wrong question, but the question is all about DDL Rollback... Since it is mentioned in BOL that DDL statements cannot be rolled back then why the Table exists?</description><pubDate>Tue, 06 Oct 2009 04:35:31 GMT</pubDate><dc:creator>Hari.Sharma</dc:creator></item><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>I got it wrong, thought it was a trick question about aliasing transactions.  I had forgotten you could do that, although it makes sense that you can now that I think about it.  Shame on me!</description><pubDate>Tue, 06 Oct 2009 03:46:59 GMT</pubDate><dc:creator>Chris Houghton</dc:creator></item><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>to do rollback in a right way,I wrote:-----------------BEGIN Tran t1 DROP TABLE TgoROLLBACK GO----------------SELECT * FROM Tthe Question of the Day was wrong, I guess, so, was completed with errors. The transaction was used before cross the word "go" so, ---------------------------------BEGIN Tran t1 DROP TABLE TROLLBACK Tran GO---------------------------------rollback doesn't raw </description><pubDate>Mon, 05 Oct 2009 20:03:23 GMT</pubDate><dc:creator>ramonaraujop</dc:creator></item><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>Ack, weird. I tried it again and got the expected results as well. I hate Mondays.</description><pubDate>Mon, 05 Oct 2009 09:07:08 GMT</pubDate><dc:creator>Richard Sisk</dc:creator></item><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>No idea.  I just copied your code to SSMS and it ran just fine returning the expected results.</description><pubDate>Mon, 05 Oct 2009 08:39:07 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>Sure, I reformatted as well, but that doesn't explain why my results were different than the posted answer. Here is the query I ran, looks the same as the QOD.CREATE TABLE T ( ID int NOT NULL, Code varchar(10) NULL)INSERT INTO T   SELECT 1,'AAAA'GO---------------------------------BEGIN Tran t1 DROP TABLE TROLLBACK Tran GO---------------------------------SELECT * FROM T</description><pubDate>Mon, 05 Oct 2009 08:36:02 GMT</pubDate><dc:creator>Richard Sisk</dc:creator></item><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>I had to fix the code (formatting, nothing else) when I tested the code in SSMS.</description><pubDate>Mon, 05 Oct 2009 08:29:31 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>Huh, what?!  I got the following when I tested my answer...(1 row(s) affected)Msg 208, Level 16, State 1, Line 2Invalid object name 'T'.Where did I go wrong in my life...</description><pubDate>Mon, 05 Oct 2009 08:19:10 GMT</pubDate><dc:creator>Richard Sisk</dc:creator></item><item><title>DDL Rollback</title><link>http://www.sqlservercentral.com/Forums/Topic797412-555-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/Rollback/67063/"&gt;DDL Rollback&lt;/A&gt;[/B]</description><pubDate>Sat, 03 Oct 2009 11:08:26 GMT</pubDate><dc:creator>Hari.Sharma</dc:creator></item></channel></rss>