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


Truncate rollback


Truncate rollback

Author
Message
Ninja's_RGR'us
Ninja's_RGR'us
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28941 Visits: 9671
Comments posted to this topic are about the item Truncate rollback
tasneem 27027
tasneem 27027
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 11
use tempdb
go
create table a (b int)
go
insert into a (b) values (1), (2), (3)

select * from a

begin tran
truncate table a

select * from a

rollback tran

select * from a

drop table a

This would ideally give you an exception at the insert statement. Because as far I know the comma seperated value insertion as mentioned in the above insert statement is incorrect. So answer should be an exception/error
TheRedneckDBA
TheRedneckDBA
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2512 Visits: 2610
Doh! I've missed three in a row now. Good one though!

The Redneck DBA
Pulivarthi Sasidhar
Pulivarthi Sasidhar
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1690 Visits: 1021
hi,



insert into a (b) values (1), (2), (3)

The above works fine...

The following statement gives error

insert into a (b) values 1,2, 3

please explain brief.....that what () means is :- as individual Insertion of each value or like Union all.....
Open Minded
Open Minded
SSC Veteran
SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)

Group: General Forum Members
Points: 260 Visits: 567
The newbie was partially right, when I pasted the statements, it erred at
insert into a (b) values (1), (2), (3)


I am using SQL Server 2005. I dug around the Internet, and saw it is supposed to work with MySql and Sql Server 2008?

I got the answer right because the point was about rollback. Does everyone who answered right or wrong, will get half-points instead? Whistling
Abrar Ahmad_
Abrar Ahmad_
SSC-Addicted
SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)

Group: General Forum Members
Points: 448 Visits: 1296
Goodish, easy hunt. but for the only SQL Server 2008 users.:-D

It means its good to be updated. Cool ... Hehe


Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11020 Visits: 11994
Good question. Not sure why it's worth 2 points; knowing that TRUNCATE can be rolled back should be elementary knowledge.

Abrar Ahmad_ (4/22/2010)
Goodish, easy hunt. but for the only SQL Server 2008 users.:-D

Why is it only for SQL 2008 users? You are not supposed to answer by running the code, but to guess based on your knowledge. If you follow announcements and read articles, you know about the new INSERT syntax in SQL2008. (But it would have been better if the words "SQL Server 2008" had been included somewhere in the question).


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Kingston Dhasian
Kingston Dhasian
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3699 Visits: 5180
Nice question. Not many know that even a TRUNCATE can be rolled back.

Some people as mentioned might get tricked by the INSERT statement and may choose the wrong answer.

But on the other side, users who simply copy and paste the code in 2005 to know the answer will get what they deserve 0 points:-D


Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Malcolm Daughtree
Malcolm Daughtree
SSC Veteran
SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)

Group: General Forum Members
Points: 289 Visits: 335
Yep !! It errored. But I'm being pedantic. Suggest you post psuedo code instead cos there are people out there who run this stuff and quite rightly the correct answer is ERROR.

CodeOn
:-P
Koen Verbeeck
Koen Verbeeck
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27419 Visits: 13268
Hmmm, not really a good question, as the answer depends on what system you use.
And no, knowing that it should work on 2008 is not an argument. In that case, it should explicitly say that the question is about 2008. If it is not mentioned, I assume it is for all systems (or at least 2000 and higher).

I'm a 2005 user and unfortunately haven't got the change yet to work with 2008 (why don't those clients upgrade their systems, aargh), so I immediately choose Error.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
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