Output Parameter

  • Comments posted to this topic are about the item Output Parameter

  • Nice question - a good way to start my week

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • I don't like this question because 1) it has nothing to do with output parameters, 2) a 'SELECT TOP' statement does not guarantee output values without an 'ORDER BY' clause. Strictly speaking, the database engine may return any of the five values from the '@table' table. So both the 1st and the 2nd answers are possible correct answers (and the total number of those answers is 5^3 = 125).

  • I like the idea of the question, but it could have been worked out better, as vk-kirov mentioned.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • +1 on the order by and 2 points on this one seemed like a little much ;-).

  • Ninja's_RGR'us (11/21/2011)


    +1 on the order by and 2 points on this one seemed like a little much ;-).

    The 2 points is just to make your Mondays a bit more bearable πŸ™‚

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Koen Verbeeck (11/21/2011)


    Ninja's_RGR'us (11/21/2011)


    +1 on the order by and 2 points on this one seemed like a little much ;-).

    The 2 points is just to make your Mondays a bit more bearable πŸ™‚

    Fun question, but not to be taken too seriously (as the correct answer, as vvkirov pointed out, is "it depends...") and I agree that 2 points seems a bit much.

    edit: I hate sticky shift keys.

    Tom

  • L' Eomot InversΓ© (11/21/2011)


    Koen Verbeeck (11/21/2011)


    Ninja's_RGR'us (11/21/2011)


    +1 on the order by and 2 points on this one seemed like a little much ;-).

    The 2 points is just to make your Mondays a bit more bearable πŸ™‚

    Fun question, but not to be taken too seriously (as the correct answer, as vvkirov pointed out, is "it depends...") and I agree that 2 points seems a bit much.

    edit: I hate sticky shift keys.

    I know it depends, but I'm getting sick of making that argument so I was hoping one of you guys would take care ot that! πŸ˜‰

  • L' Eomot InversΓ© (11/21/2011)


    edit: I hate sticky shift keys.

    Then don't waste so much time thinking what you are going to type while holding Shift. πŸ˜€

    (it happens to me on a weekly basis)

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Ninja's_RGR'us (11/21/2011)


    I know it depends, but I'm getting sick of making that argument so I was hoping one of you guys would take care ot that! πŸ˜‰

    I'll never tire of repeating this, until (hopefully) some day I don't have to do it anymore.

    So here goes - without ORDER BY, there is no way to predict which of the five rows will be the TOP 1 row; answer options 1 and 2 are both correct (and there are lots of other correct answer options as well).

    The explanation is also partially misleading.

    "But if your replace the "SELECT TOP 1 t1 FROM @table" with "SET @ReorderPoint= (SELECT TOP 1 t1 FROM @table)", it give error message like "Error converting data type varchar to int.". "

    Well - it may do that. But if the row that happens to be returned by the TOP 1 without ORDER BY is one of the rows with t1 equal to 145.87, 1059.31, or 38.49, it will happily convert taht value from varchar to int (or decimal, or float).

    Finally, the "TOP 1" syntax is still supported, but Microsoft recommends against using it. In the officianl syntax, parentheses are required: "TOP (1)".

    See http://msdn.microsoft.com/en-us/library/ms189463.aspx


    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/

  • Ninja's_RGR'us (11/21/2011)


    I know it depends, but I'm getting sick of making that argument so I was hoping one of you guys would take care ot that! πŸ˜‰

    IT DEPENDS!

    There I did it for you πŸ™‚

    since it didn't have an IT DEPENDS answer, I went with one of the likely assumption ones and got it right.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • mtassin (11/21/2011)


    Ninja's_RGR'us (11/21/2011)


    I know it depends, but I'm getting sick of making that argument so I was hoping one of you guys would take care ot that! πŸ˜‰

    IT DEPENDS!

    There I did it for you πŸ™‚

    Those letters have been worn out of the keyboard I use, I need to use ctrl-numpad to type in those letters. Too much trouble :-D.

  • Ninja's_RGR'us (11/21/2011)


    mtassin (11/21/2011)


    Ninja's_RGR'us (11/21/2011)


    I know it depends, but I'm getting sick of making that argument so I was hoping one of you guys would take care ot that! πŸ˜‰

    IT DEPENDS!

    There I did it for you πŸ™‚

    Those letters have been worn out of the keyboard I use, I need to use ctrl-numpad to type in those letters. Too much trouble :-D.

    I had the same problem. I got lucky and purchasing bought me a new $15 PS2 keyboard. I can type IT DEPENDS for a few more months again.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • mtassin (11/21/2011)


    Ninja's_RGR'us (11/21/2011)


    mtassin (11/21/2011)


    Ninja's_RGR'us (11/21/2011)


    I know it depends, but I'm getting sick of making that argument so I was hoping one of you guys would take care ot that! πŸ˜‰

    IT DEPENDS!

    There I did it for you πŸ™‚

    Those letters have been worn out of the keyboard I use, I need to use ctrl-numpad to type in those letters. Too much trouble :-D.

    I had the same problem. I got lucky and purchasing bought me a new $15 PS2 keyboard. I can type IT DEPENDS for a few more months again.

    I should get a macro program to be able to just hit something like ctrl-alt-shit-i :-D.

    And with shipping + install it's like 200$. A new computer might almost be cheaper at that point! Unless I buy what I really want! :hehe:

  • L' Eomot InversΓ© (11/21/2011)


    Nice avatar

    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 - 1 through 15 (of 30 total)

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