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

Fun with IDENTITY - Part I Expand / Collapse
Author
Message
Posted Wednesday, September 29, 2010 4:40 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 12:32 AM
Points: 18,855, Visits: 12,439
Thanks for the question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #995065
Posted Wednesday, September 29, 2010 6:02 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:23 AM
Points: 1,354, Visits: 436
UMG Developer (9/28/2010)
I agree, nice question, but it would have been even better with a fourth option: 1-Boston;2-New Delhi

Without that option it was really a test of transactions, not of IDENTITY. (Maybe that was the point to through people off the scent?)


Agreed, reading the question I was thinking would New Delhi be 2 or 3. When 2 was not an option that answer was clear.
Post #995111
Posted Wednesday, September 29, 2010 6:06 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, June 14, 2013 7:34 AM
Points: 2,865, Visits: 2,472
Good question - after the fun with transactions, nobody should have gotten this one wrong

Steve Jimmo
Sr DBA
“If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan
Post #995115
Posted Wednesday, September 29, 2010 8:17 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, March 15, 2013 2:43 PM
Points: 3,924, Visits: 1,554
Easy one. With Begin and Rollback Transaction included in question it's easy to select correct answer.

SQL DBA.
Post #995264
Posted Wednesday, September 29, 2010 8:23 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 8:36 AM
Points: 2,681, Visits: 2,423
It's nice to get a QoTD once in a while without a trick. Nice question.
Post #995277
Posted Wednesday, September 29, 2010 9:27 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: Wednesday, June 12, 2013 11:07 AM
Points: 586, Visits: 365
I agree, a forth option of 1-Boston;2-New Delhi would have made the question better. With a forth option, I would have had to think more about the impact of a rolled back transaction has on the Identity values to get the correct answer.

Good question though.



Post #995364
Posted Thursday, September 30, 2010 6:28 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:26 AM
Points: 1,384, Visits: 4,877
edit - replied to the wrong topic!
Post #995862
Posted Friday, October 01, 2010 9:24 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, June 13, 2013 11:23 AM
Points: 96, Visits: 266
Why would you ever use "rollback transaction" unless with an "if @@error" statement?
Post #996773
Posted Friday, October 01, 2010 11:28 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:53 PM
Points: 7,182, Visits: 7,281
The correct answer "It depends" isn't available as an option.

How many rows are produced depends on the IMPLICIT_TRANSACTIONS setting.

If ANSI_DEFAULTS or IMPLICIT_TRANSACTIONS have been set on, this code will produce no rows (just an error message for the third insert, which is an attempt to insert into a nonexistent table). The BEGIN TRAN statement won't open a transaction because there is already an active transaction.

But most connections default to autocommit mode ( so IMPLICIT_TRANSACTIONS is off) so the code will produce 2 rows, as in the supposedly correct answer.

As no rows wasn't an option, it was possible to deduce that IMPLICIT_TRANSACTIONS had to be OFF so that the 2-row answer was the one expected by the person who set the question.





Tom
Is minic a gheibheann béal oscailte dorn dúnta.
Is minig a cheapas beul fosgailte dòrn dùinte.

http://es.linkedin.com/in/tomthomsonsoftware
Post #996872
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse