Truncate rollback

  • [font="Verdana"]

    Ninja's_RGR'us (4/22/2010)


    Hugo Kornelis (4/22/2010)


    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)


    [font="Verdana"]Goodish, easy hunt. but for the only SQL Server 2008 users.:-D[/font]

    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).

    I toyed with the idea of including 2008 in there, but I felt it gave better challenge if the code couldn't be run.

    I would like to add that... the QODs like things do care about very small tiny hidden clues/tricks which can deceive any experienced person. So in such critical Quests the Quest Statement must be crystal clear, otherwise no-one can predict vague options/solutions.

    Please, I disagree with this thought completely. "I toyed with the idea of including 2008".

    And specially, i am working with Sql Server 2008 for the last 1.5 years or so.

    Thanks [/font]

  • Abrar Ahmad_ (4/22/2010)


    [font="Verdana"]

    Ninja's_RGR'us (4/22/2010)


    Hugo Kornelis (4/22/2010)


    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)


    [font="Verdana"]Goodish, easy hunt. but for the only SQL Server 2008 users.:-D[/font]

    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).

    I toyed with the idea of including 2008 in there, but I felt it gave better challenge if the code couldn't be run.

    I would like to add that... the QODs like things do care about very small tiny hidden clues/tricks which can deceive any experienced person. So in such critical Quests the Quest Statement must be crystal clear, otherwise no-one can predict vague options/solutions.

    Please, I disagree with this thought completely. "I toyed with the idea of including 2008".

    And specially, i am working with Sql Server 2008 for the last 1.5 years or so.

    Thanks [/font]

    Thanks for the input, I'll keep this in mind when I post again.

  • Ninja's_RGR'us (4/22/2010)

    I toyed with the idea of including 2008 in there, but I felt it gave better challenge if the code couldn't be run.

    Thing is you didn't need to run the code to get it wrong if you weren't familiar with the new 2008 syntax on the insert statement. Many questions in the past have included syntax errors in statements to highlight lots of issues even when they are nothing to do with the subject as I have been caught out on them in the past.

    So like many, as a specific version wasn't included in the question, I assumed based on my knowledge of 2000/2005 that it would error frst and that this was probably a trick question.

    I don't think it's hard to write the perfect question if it's just given a little though on the basics e.g. test the question and answers on different versions and specify which ones you're referring to in the question. Being more specific in a question doesn't mean you are simplifying the question but can mean you don't distract people from the learning involved in getting the answer. 😀

  • Ian Elliott (4/22/2010)


    I don't think it's hard to write the perfect question if it's just given a little though on the basics e.g. test the question and answers on different versions and specify which ones you're referring to in the question. Being more specific in a question doesn't mean you are simplifying the question but can mean you don't distract people from the learning involved in getting the answer. 😀

    As an author of eleven questions so far (2 of them not yet published), I can only say that you are wrong. I tried very hard to get the questions perfect, all 11 of them, and I still earned criticism (some very justified, some ... ahem ... less so) on all of them.

    If you want to write questions that are not a complete giveaway and that include a learning opportunity for at least some of the visitors, it IS, definitely, very very very hard to get even close to perfect.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • [font="Verdana"]

    Hugo Kornelis (4/22/2010)


    Ian Elliott (4/22/2010)


    I don't think it's hard to write the perfect question if it's just given a little though on the basics e.g. test the question and answers on different versions and specify which ones you're referring to in the question. Being more specific in a question doesn't mean you are simplifying the question but can mean you don't distract people from the learning involved in getting the answer. 😀

    As an author of eleven questions ......

    , very very very hard to get even close to perfect.

    but at least a try 😀

    [/font]

  • Hugo Kornelis (4/22/2010)


    As an author of eleven questions so far (2 of them not yet published), I can only say that you are wrong. I tried very hard to get the questions perfect, all 11 of them, and I still earned criticism (some very justified, some ... ahem ... less so) on all of them.

    If you want to write questions that are not a complete giveaway and that include a learning opportunity for at least some of the visitors, it IS, definitely, very very very hard to get even close to perfect.

    Sorry I get what you're saying and while I agree that in some cases you are correct its not in most of the others I've seen like this. Most of the issues I've had with questions are not because of the difficulty associated with the answer it's been not knowing which environment I'm supposed to be using to answer the question and thereby not focussing on the real question.

    The bottom line is how can you answer a question correctly if there are different answers depending on which sql environment you use and you have to just guess which one the author may be referring to and hope you get it right. That is not as much about learning of the important issues, similarities, differences between versions as it is your guess on that particular day.

    Don't get me wrong you can be too precise and I wouldn't advocate specifying all/most possible environment settings for every question but giving the basics will mean that people aren't worrying about tricks and will concentrate more an answering the question that was intended.

    I've seen this in too many questions whereby just giving the sql server version would not have made any impact on the goal of the original question or made it any easier but would've helped people to concentrate more on the important point of the question.

    Hey just my two cents though. I do appreciate everyone who submits questions as more often than not I learn something new whether i get the question right or not. It would just be nice to get a question wrong because I didn't know the answer as opposed to not guessing which environment I was supposed to be answering about. 😛

  • Hugo Kornelis (4/22/2010)


    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)


    [font="Verdana"]Goodish, easy hunt. but for the only SQL Server 2008 users.:-D[/font]

    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).

    It probably would have been better if it was inserted with a unioned select statement, so it would work in any version of sql.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • To be fair, even if you saw the "Possible Error" in the INSERT (if you didn't know this was a SQL 2008 feature, like me) or if you ran it and got an error because of the insert, the question explicitly specified "How many rows are returned in the last select?". If you account for this, the only criticism of the question that really makes sense was Christian Buettner's (that implicit transactions will make that last select fail).

    If you get an error on the insert, then none of the given answers is relevant - you cannot choose any of the given options, because the last select never even runs.

    http://poorsql.com for T-SQL formatting: free as in speech, free as in beer, free to run in SSMS or on your version control server - free however you want it.

  • Tao Klerks (4/22/2010)


    To be fair, even if you saw the "Possible Error" in the INSERT (if you didn't know this was a SQL 2008 feature, like me) or if you ran it and got an error because of the insert, the question explicitly specified "How many rows are returned in the last select?". If you account for this, the only criticism of the question that really makes sense was Christian Buettner's (that implicit transactions will make that last select fail).

    If you get an error on the insert, then none of the given answers is relevant - you cannot choose any of the given options, because the last select never even runs.

    Greetings,

    One of the answers was "error". That answer is very relevant to a person who works with SQL 2005 most of the time. It might have been good to put something in the title or question to state it was based on general SQL standards or a specific version of SQL. This would help others to consider the SQL code as being valid even if it is not for their specific version.

    Quite simply, this question appears to have 2 correct answers. If you are using SQL 2008, then it would be 3. If you are using SQL 2005, then it would be error. You don't need to run the code either to see this. Those who do use the SQL 2005 have been taught by the school of hard knocks that you can't insert multiple records by the values. So, whenever they see code with that, they see an immediate error.

    Just my .02 :hehe:

  • terrance.steadman (4/22/2010)


    Tao Klerks (4/22/2010)


    To be fair, even if you saw the "Possible Error" in the INSERT (if you didn't know this was a SQL 2008 feature, like me) or if you ran it and got an error because of the insert, the question explicitly specified "How many rows are returned in the last select?". If you account for this, the only criticism of the question that really makes sense was Christian Buettner's (that implicit transactions will make that last select fail).

    If you get an error on the insert, then none of the given answers is relevant - you cannot choose any of the given options, because the last select never even runs.

    Greetings,

    One of the answers was "error". That answer is very relevant to a person who works with SQL 2005 most of the time. It might have been good to put something in the title or question to state it was based on general SQL standards or a specific version of SQL. This would help others to consider the SQL code as being valid even if it is not for their specific version.

    Quite simply, this question appears to have 2 correct answers. If you are using SQL 2008, then it would be 3. If you are using SQL 2005, then it would be error. You don't need to run the code either to see this. Those who do use the SQL 2005 have been taught by the school of hard knocks that you can't insert multiple records by the values. So, whenever they see code with that, they see an immediate error.

    Just my .02 :hehe:

    Though I do agree (and have already said) that it would have been better to state the SQL 2008 requirement in the question,. I do not agree with your point of view.

    As Tao wrote (and you even quoted him), the question was specifically what the last select returns. Can you please tell me how, in any version of SQL Server, that last select can return an error?


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • I have to say that this is a poor question.

    The insert statement is specific to SS2008, and not earlier versions. Thus the insert will fail unless on SS2008. The question should state that. This has been debated at length previously, that we should include versions if specific versions are needed for the answer.

    I knew that the rollback would work on the truncate, and that there would be 3 rows again in the table. But the data wouldn't be there, and you would have a "Msg 102, Level 15, State 1, Line 3 Incorrect syntax near ','." error

    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

  • Greetings,

    In the mindset of SQL 2005, this would look like a trick question. So, even though the question is what would the last SELECT statement show. Logically, it would never get there so it would show an error. Maybe if one of the answers then was not error, but NULL, then that would have helped show that this was supposed to be a SQL generic question and not a trick question to a SQL 2005 user.

  • Kingston Dhasian (4/22/2010)


    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😀

    I didn't have to copy/paste to know that code won't work on SQL Server 2005. So, I chose error without looking further at the code. The lesson that TRUNCATE rolls back is a good one, though.

  • I agree, a very poor question indeed. At a minimum, it should have given the minimum version of SQL to run on. I only have 2000 and 2005. Incorrect syntax on the insert statement.

    -- You can't be late until you show up.

  • The correct answer to this question should be 'Error'. :w00t:

    The guys who marked 'Error' deserve the points.

Viewing 15 posts - 31 through 45 (of 87 total)

You must be logged in to reply to this topic. Login to reply