SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


DDL Rollback


DDL Rollback

Author
Message
Hari.Sharma
Hari.Sharma
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1774 Visits: 455
Comments posted to this topic are about the item DDL Rollback

Cheers,
Hari
Tips & Tricks for SQL BI Developers

Richard Sisk
Richard Sisk
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2045 Visits: 210
Huh, what?! I got the following when I tested my answer...

(1 row(s) affected)
Msg 208, Level 16, State 1, Line 2
Invalid object name 'T'.


Where did I go wrong in my life...
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)

Group: General Forum Members
Points: 51480 Visits: 38684
I had to fix the code (formatting, nothing else) when I tested the code in SSMS.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Richard Sisk
Richard Sisk
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2045 Visits: 210
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 T
ROLLBACK Tran
GO
---------------------------------
SELECT * FROM T
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)

Group: General Forum Members
Points: 51480 Visits: 38684
No idea. I just copied your code to SSMS and it ran just fine returning the expected results.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Richard Sisk
Richard Sisk
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2045 Visits: 210
Ack, weird. I tried it again and got the expected results as well. I hate Mondays.
ramonaraujop
ramonaraujop
Grasshopper
Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)

Group: General Forum Members
Points: 23 Visits: 85
to do rollback in a right way,
I wrote:
-----------------
BEGIN Tran t1
DROP TABLE T
go
ROLLBACK
GO
----------------
SELECT * FROM T

the 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 T
ROLLBACK
Tran GO
---------------------------------
rollback doesn't raw
Chris Houghton
Chris Houghton
Right there with Babe
Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)

Group: General Forum Members
Points: 746 Visits: 1707
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!
Hari.Sharma
Hari.Sharma
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1774 Visits: 455
ramonaraujop (10/5/2009)
to do rollback in a right way,
I wrote:
-----------------
BEGIN Tran t1
DROP TABLE T
go
ROLLBACK
GO
----------------
SELECT * FROM T

the Question of the Day was wrong, I guess, so, was completed with errors.
The transaction was used before cross the word "go" so,



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?

Cheers,
Hari
Tips & Tricks for SQL BI Developers

Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)

Group: General Forum Members
Points: 51480 Visits: 38684
Hari.Sharma (10/6/2009)
ramonaraujop (10/5/2009)
to do rollback in a right way,
I wrote:
-----------------
BEGIN Tran t1
DROP TABLE T
go
ROLLBACK
GO
----------------
SELECT * FROM T

the Question of the Day was wrong, I guess, so, was completed with errors.
The transaction was used before cross the word "go" so,



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?


The following is directly from the referenced link in the answer to this question:


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.


Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search