Queries

  • Comments posted to this topic are about the item Queries

  • I was completely not able to get this question!

    Could have been phrased better..

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • I guessed 7 and got it wrong.

    I've just created a test database to try this.

    Including actual execution plan shows nothing...

    displaying estimated execution plan shows 8 queries, however, these 2 are counted as 1:

    SET QUOTED_IDENTIFIER ON; SET ARITHABORT ON;

    And both BEGIN TRAN and COMMIT are counted as queries in their own right. I suppose that's fair.

    Interestingly, if you move QUOTED_IDENTIFIER to be the last one, estimated query plan counts it and COMMIT together as one query. I tried that hoping to see it say 9 queries but not what I expected at all. Seems like yet another quirk of the estimated query plan to me rather than being anything useful regarding the nature of the commands.

    I hope someone can elaborate on this.

  • Not able to get the today's question :w00t:

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Well, this question definitely has more than one correct answer. If you look at the actual execution plan, the correct answer is 0.



    Ole Kristian Velstadbråten Bangås - Virinco - Facebook - Twitter

    Concatenating Row Values in Transact-SQL[/url]

  • The only correct answer is 0.

    There are 8 statements in the estimated execution plan, but no queries.

    From BOL:

    A query is a request for data that is stored in SQL Server.

    Query Fundamentals

    There isn't a single statement in the batch that does a request for data, hence no queries.

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

  • I select 0 option but get it wrong... 😉

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • That was ...

    ... interesting:rolleyes:


    Just because you're right doesn't mean everybody else is wrong.

  • And what shall we learn from that?

  • I agree with Koen. Those are statements. As the estimated execution plan doesn't know better it will divide this up into 8 parts. Why the quoted_identifier setting always will go with the next statement is beyond me, but is of no consequense for the answer.

    As we have learned before, the estimated execution plan can lie to us, e.g. because of function calls. I would say that the actual execution plan is the only non-lying report of this query batch, and as stated previously, the actual number of queries against the engine is 0.

  • Koen Verbeeck (11/28/2012)


    The only correct answer is 0.

    There are 8 statements in the estimated execution plan, but no queries.

    From BOL:

    A query is a request for data that is stored in SQL Server.

    Query Fundamentals

    There isn't a single statement in the batch that does a request for data, hence no queries.

    +1

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

  • Sorry, no. 0 is the correct answer, as each element of this question is a statement, not a query.

    As above, BOL defines a query as a request for data, not a request to set an environment variable.

    Poor question today.

    ---

    Note to developers:
    CAST(SUBSTRING(CAST(FLOOR(NULLIF(ISNULL(COALESCE(1,NULL),NULL),NULL)) AS CHAR(1)),1,1) AS INT) == 1
    So why complicate your code AND MAKE MY JOB HARDER??!:crazy:

    Want to get the best help? Click here https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help (Jeff Moden)
    My blog: http://uksqldba.blogspot.com
    Visit http://www.DerekColley.co.uk to find out more about me.

  • I second guessed that the question meant statements as opposed to queries as otherwise it made no sense at all. I also second guessed that it wouldn't be 9 as I'd assumed so I ran a trace. I've been unable to capture the SET QUOTED_IDENTIFIER statement in a trace using SQL:stmtcompleted event at all. This applies whether I set it on or off, as part of a transaction or out of it, as part of a bunch of set statements or on its own. Even though I can't capture the statement, running it does have the expected impact. It may not have much in the way of practical implication but there is something interesting going on with the SET QUOTED_IDENTIFIER statement which the question has highlighted.

  • I didn't understand the question at all, so guessed. Having read the explanation I was none the wiser.

    So I tried it, and the execution plan was empty.

    confused.com

  • Koen Verbeeck (11/28/2012)


    The only correct answer is 0.

    There are 8 statements in the estimated execution plan, but no queries.

    From BOL:

    A query is a request for data that is stored in SQL Server.

    Query Fundamentals

    There isn't a single statement in the batch that does a request for data, hence no queries.

    QFT

    Another +1 from me

Viewing 15 posts - 1 through 15 (of 61 total)

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