|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Yesterday @ 5:12 AM
Points: 649,
Visits: 686
|
|
Hugo Kornelis (1/4/2011) I replied wrong - I saw the rollback after the truncate, assumed the question intended to test my understanding that a truncate can be rolled back, and then replied. I had not seen the missing ALL after the UNION operators, nor noticed the duplicate row. Whew! If I got it wrong for the same reason Hugo did, then I must be doing okay. 
ron
----- a haiku...
NULL is not zero NULL is not an empty string NULL is the unknown
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 1:49 PM
Points: 1,787,
Visits: 3,324
|
|
Got it wrong because I misread the UNION for UNION ALL. I focused on the transaction rollback and therefore counted the number rows with 3 in it in the first insert statement.
Good question. A good reminder that assumptions seldom leads to any good!
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 7:15 AM
Points: 2,864,
Visits: 2,467
|
|
Got it wrong, but learned something - which is the key
Hugo, The knowledge tested is good, but the way the question has been built suggests to me that the author tried to trick people into overlooking key elements
Many have said, and usually do of most questions that the QOD's are tricks but I question the abilities of many. Don't take offense, but answer this (not necessarily to me) - a portion of many DBA's time is spent reviewing code from developers who have varing levels of expertise in writing SQL code. Isn't part of what we are supposed to be doing looking for things such as this?
I know, fine one to talk when I got it wrong, but...
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
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 24, 2013 9:59 PM
Points: 1,354,
Visits: 1,299
|
|
sjimmo (1/4/2011)
Got it wrong, but learned something - which is the key Hugo, The knowledge tested is good, but the way the question has been built suggests to me that the author tried to trick people into overlooking key elements Many have said, and usually do of most questions that the QOD's are tricks but I question the abilities of many. Don't take offense, but answer this (not necessarily to me) - a portion of many DBA's time is spent reviewing code from developers who have varing levels of expertise in writing SQL code. Isn't part of what we are supposed to be doing looking for things such as this? I know, fine one to talk when I got it wrong, but...  Agreed but normally when you are helping someone troubleshoot a problem, you're given the code and what the output is and what it should be. It's easy to figure out the problem that way.
On these QOTD's, we are given a subject that says one thing, leading us to believe that's what is being tested, and then when you look at the answer, it was all about something else completely different.
If we got the output provided to us and was asked to state why some of the records were missing, I bet more people would have figured out it was due to the "UNION" versus "UNION ALL" but that's not the way the question was presented.
|
|
|
|
|
SSC-Insane
         
Group: General Forum Members
Last Login: Today @ 2:27 PM
Points: 21,357,
Visits: 9,537
|
|
Hugo Kornelis (1/4/2011) I replied wrong - I saw the rollback after the truncate, assumed the question intended to test my understanding that a truncate can be rolled back, and then replied. I had not seen the missing ALL after the UNION operators, nor noticed the duplicate row.
The knowledge tested is good, but the way the question has been built suggests to me that the author tried to trick people into overlooking key elements. It would have been better to make two questions, one about rolling back after truncate table (with no other elements to confuse the reader), and one that uses UNION and inserts a duplicate row (again, with no other elements to distract the reader).
Ditto. learned nothing here. Moreover I "never" use unions to load data into table unless I'm creating test data... especially with 15 manuel inserts.
I think most unknown fact in this question is that the truncate will be rolled back. Not that there's a difference between union and union all.
I would rather have seen a question hammering on the former point rather than the latter.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 12:39 PM
Points: 3,397,
Visits: 3,405
|
|
| I fell into the same trap. I overlooked the WHERE clause. Not sure I understand what the point of that was?
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, June 07, 2012 3:39 AM
Points: 57,
Visits: 62
|
|
Hardy21 (1/4/2011)
cengland0 (1/4/2011)
Hugo Kornelis (1/4/2011) I replied wrong - I saw the rollback after the truncate, assumed the question intended to test my understanding that a truncate can be rolled back, and then replied. I had not seen the missing ALL after the UNION operators, nor noticed the duplicate row.
The knowledge tested is good, but the way the question has been built suggests to me that the author tried to trick people into overlooking key elements. It would have been better to make two questions, one about rolling back after truncate table (with no other elements to confuse the reader), and one that uses UNION and inserts a duplicate row (again, with no other elements to distract the reader).Exactly the same thing that I did. I looked at the subject of the QOTD and it said "TRUNCATE in TRANSACTION." I did notice it didn't say UNION ALL which I always do myself but I didn't scrutinize it enough to check for duplicates because I assumed I was being tested on the TRUNCATE command. Same with me  Question is good but title is misleading. I got it wrong but I like the way author wrote WHERE condition - value IN (column1, column2).
Was just about to say exactly the same myself. Clearly a lesson to be learned, but the author has been particularly sneaky using that heading!
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: 2 days ago @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 1:51 AM
Points: 1,971,
Visits: 1,821
|
|
CirquedeSQLeil (1/4/2011) I didn't like this question very much for the same reasons others have already noted. That said, I did learn a bit from it. I agree, I learned to read more and more carefully the qotd else nothing new under the Sun. Who has much time to spend for a qotd?
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Sunday, July 15, 2012 11:15 AM
Points: 35,
Visits: 71
|
|
Good question. Really appreciating. It giving importance to Union , Truncate in Transaction.

The IN operator used in the query is very nice. Thanks.
Thank You. Reji P R Hyderabad
Thanks.
Reji PR, Bangalore

|
|
|
|