|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Today @ 12:32 AM
Points: 18,855,
Visits: 12,439
|
|
|
|
|
|
Ten 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.
|
|
|
|
|
SSCrazy
      
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
|
|
|
|
|
Hall 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.
|
|
|
|
|
SSCrazy
      
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.
|
|
|
|
|
Mr 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.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 7:26 AM
Points: 1,384,
Visits: 4,877
|
|
| edit - replied to the wrong topic!
|
|
|
|
|
SSC 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?
|
|
|
|
|
SSCertifiable
       
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
|
|
|
|