Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

DDL Rollback Expand / Collapse
Author
Message
Posted Saturday, October 03, 2009 11:08 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, December 26, 2012 12:43 PM
Points: 1,330, Visits: 455
Comments posted to this topic are about the item DDL Rollback

Cheers,
Hari
Tips & Tricks for SQL BI Developers
Post #797412
Posted Monday, October 05, 2009 8:19 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, September 16, 2013 8:08 AM
Points: 1,987, 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...
Post #797927
Posted Monday, October 05, 2009 8:29 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 10:05 AM
Points: 22,519, Visits: 30,272
I had to fix the code (formatting, nothing else) when I tested the code in SSMS.



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)
Post #797947
Posted Monday, October 05, 2009 8:36 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, September 16, 2013 8:08 AM
Points: 1,987, 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
Post #797955
Posted Monday, October 05, 2009 8:39 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 10:05 AM
Points: 22,519, Visits: 30,272
No idea. I just copied your code to SSMS and it ran just fine returning the expected results.



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)
Post #797958
Posted Monday, October 05, 2009 9:07 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, September 16, 2013 8:08 AM
Points: 1,987, Visits: 210
Ack, weird. I tried it again and got the expected results as well. I hate Mondays.
Post #797978
Posted Monday, October 05, 2009 8:03 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, September 20, 2013 5:14 PM
Points: 21, Visits: 80
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
Post #798275
Posted Tuesday, October 06, 2009 3:46 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, March 17, 2014 11:04 AM
Points: 558, Visits: 1,454
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!

Post #798392
Posted Tuesday, October 06, 2009 4:35 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, December 26, 2012 12:43 PM
Points: 1,330, 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
Post #798412
Posted Tuesday, October 06, 2009 6:24 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 10:05 AM
Points: 22,519, Visits: 30,272
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.




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)
Post #798447
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse