Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
An esoteric little SQL brain teaser
Message
From
20/10/2013 13:11:50
 
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01585872
Message ID:
01585882
Views:
57
Can you truncate a table inside an explicit SQL transaction?

If so, does the actual truncation defer until after the commit?

>Here's a little brain teaser. This could be a "who's buried in Grant's tomb" question....or it might be a trick question.
>
>Here we go. In SQL Server, suppose you're in a SQL transaction. During the transaction, you truncate a table by issuing the TRUNCATE TABLE statement. Let's say the table had 100 rows before the TRUNCATE.
>
>Here's the question - can you issue a ROLLBACK statement and bring back the 100 rows?
>
>
>Obviously, you could cheat and try it out in SQL Server, so I'm asking for honesty.
>
>There's a story behind this question.....


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform