Create Procedure

  • I picked 1 & 3 option, because they were definitely going to throw an error. I wasn't aware of the "shouldn't use 'sp'" rule, which would make #1 doubly wrong. And I also wasn't thinking that anyone would be foolish enough to give their sproc the name of a system sproc. Which is bad on me, I normally try to think that everyone else is an utter moron 😛

  • Trick question. Don't like it.

    'Nuff said.


    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/

  • Carlo Romagnano (11/4/2015)


    If I want to be pedant, the right answer is "All of the above".

    Because of lacking of batch separator "GO".

    If you run the script no procedure is created.

    +1. Also because we should really always specify the schema.

    Gerald Britton, Pluralsight courses

  • Why can we only choose one?

  • g.britton (11/4/2015)


    Carlo Romagnano (11/4/2015)


    If I want to be pedant, the right answer is "All of the above".

    Because of lacking of batch separator "GO".

    If you run the script no procedure is created.

    +1. Also because we should really always specify the schema.

    well ... why ? 🙂

    I mean why should always specify the schema ?

  • I'm with the tricksy question that penalizes us for best coding practice crowd. Code that throws errors should not be used as much as the old sp_ prefix shouldn't be used. Bad question.

  • I blame poor wording. As I understood the question, then 1, 2, 3 was the answer. After reading what was intended, I see what was meant.:-)

  • I agree. Trick Question.

  • paul 25096 (11/4/2015)


    I think the reason "Options 1, 2 and 3" has more votes than "Option 2" is because of course you should also avoid statements that cause a syntax error. The question could have been clearer!

    Agree. Red herrings are not good before morning coffee.

    I would 'avoid' those names even before hitting <f-5>, so I would in fact avoid 1, 2, and 3. And, you could use 1 and 3 if you square-bracketed them

    Mark
    Just a cog in the wheel.

  • Iulian -207023 (11/4/2015)


    g.britton (11/4/2015)


    Carlo Romagnano (11/4/2015)


    If I want to be pedant, the right answer is "All of the above".

    Because of lacking of batch separator "GO".

    If you run the script no procedure is created.

    +1. Also because we should really always specify the schema.

    well ... why ? 🙂

    I mean why should always specify the schema ?

    To be sure the proc is going where you want it. You may have a default schema (not dbo) for your user id in the target database but you want it in dbo. Or you may want it in some other schema. Explicit is better than implicit.

    Gerald Britton, Pluralsight courses

  • I'll just throw another +1 to the "I think you should avoid syntax errors". Sure, you could fix the CREATE statements offered, but that's quite a stretch. Even then, "should" is a slippery word. I understand the desire to make the question harder, but I think clarity should be emphasized above trickiness. Something like "Which of these, if any, could introduce an unwanted performance hit..." would be a world clearer.

    Relying on the assumption that "Should avoid X" implies "X is syntactically correct" is more than a bit tenuous. Still, it's just the QotD and not our life savings, so it's not such a tragedy 🙂

  • paul 25096 (11/4/2015)


    I think the reason "Options 1, 2 and 3" has more votes than "Option 2" is because of course you should also avoid statements that cause a syntax error. The question could have been clearer!

    Agreed.

  • Great idea for a question that tried to bring up a very valid point. Unfortunately it was too ambiguous which led the discussion down a path of complaining about the question instead of discussing why we should avoid the sp_ prefix (or my preference of no prefixes) in the first place.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • I got it "wrong". Hmmm.

    I said you should avoid using 1, 2, & 3 which is correct because you can't even create the names in 1 and 3, therefore you could say you should avoid trying to use them. There was no way to know that the "correct" answer would not include 1 & 3 without guessing what the writer "meant". The writer left that specific part open for interpretation.

    The question should have said something more like "Which of these are valid, but you should avoid using when creating a stored procedure?"

    Like so many I have seen on this site, this is just another crappy trick question imo. Trick questions are not a good learning tool, and they are degrading. They only serve the purpose of trying to make someone look dumb or lower scores. Stop making questions to be "tricky" and just keep it simple.

  • Hugo Kornelis (11/4/2015)


    Trick question. Don't like it.

    'Nuff said.

    +1

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

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

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