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 12345»»»

Truncate rollback Expand / Collapse
Author
Message
Posted Wednesday, April 21, 2010 9:20 PM


SSC-Insane

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

Group: General Forum Members
Last Login: Yesterday @ 4:00 AM
Points: 21,397, Visits: 9,612
Comments posted to this topic are about the item Truncate rollback
Post #908285
Posted Wednesday, April 21, 2010 9:44 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, May 20, 2010 8:05 PM
Points: 11, 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
Post #908293
Posted Wednesday, April 21, 2010 10:04 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 7:37 AM
Points: 1,509, Visits: 2,163
Doh! I've missed three in a row now. Good one though!

Jason Shadonix
MCTS, SQL 2005
Post #908300
Posted Wednesday, April 21, 2010 11:46 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, August 21, 2014 6:46 AM
Points: 1,059, Visits: 697
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.....
Post #908321
Posted Wednesday, April 21, 2010 11:54 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 18, 2014 4:04 AM
Points: 176, 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?
Post #908327
Posted Thursday, April 22, 2010 12:13 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 11:00 PM
Points: 211, Visits: 1,113
Goodish, easy hunt. but for the only SQL Server 2008 users.

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

Post #908334
Posted Thursday, April 22, 2010 12:29 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:20 PM
Points: 5,975, Visits: 8,236
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.

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
Post #908341
Posted Thursday, April 22, 2010 12:32 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, August 22, 2014 12:13 AM
Points: 2,631, Visits: 4,723
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



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/
Post #908343
Posted Thursday, April 22, 2010 12:38 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, November 2, 2011 9:50 PM
Points: 189, 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
Post #908345
Posted Thursday, April 22, 2010 12:39 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:16 AM
Points: 13,621, Visits: 10,507
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?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #908347
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse