Commenting in Dynamic query

  • Thomas Abraham (8/7/2012)


    SQLRNNR (8/7/2012)


    I doubt this question is in regards to any discussion from the first question.

    Questions are usually scheduled about a month in advance.

    If that is indeed the case, then I apologize for seeing intent where there was none.

    😎

    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

  • SQLRNNR (8/7/2012)


    mtassin (8/7/2012)


    And what happened to Steve's statement of NO MORE IMAGES for queries?

    Steve? Come on...

    Not that it matters for this one... but it did look like a rewrite and fix of the original... I didn't even look closely at it.

    This question was more than likely scheduled a month ago - long before the new mandate about images in questions.

    I thought it was quite similar to the first but also noticed that the Select count(*) was changed to a Select *. That change alone eliminates any answer that has a 1 in it, even if you don't understand scope of table variables. 😀

    As far as I remember, the "Select count(*)" was changed by Steve after the discussion on the previous question and originally had a "Select *".

    However, I don't see how does it eliminates the answers with 1 in them.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares (8/7/2012)


    SQLRNNR (8/7/2012)


    mtassin (8/7/2012)


    And what happened to Steve's statement of NO MORE IMAGES for queries?

    Steve? Come on...

    Not that it matters for this one... but it did look like a rewrite and fix of the original... I didn't even look closely at it.

    This question was more than likely scheduled a month ago - long before the new mandate about images in questions.

    I thought it was quite similar to the first but also noticed that the Select count(*) was changed to a Select *. That change alone eliminates any answer that has a 1 in it, even if you don't understand scope of table variables. 😀

    As far as I remember, the "Select count(*)" was changed by Steve after the discussion on the previous question and originally had a "Select *".

    However, I don't see how does it eliminates the answers with 1 in them.

    Look at the where filter. The only value inserted into the table is 1. The where filter is only selecting the values of 0. None of those queries should return a result set.

    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

  • Luis Cazares (8/7/2012)


    SQLRNNR (8/7/2012)


    mtassin (8/7/2012)


    And what happened to Steve's statement of NO MORE IMAGES for queries?

    Steve? Come on...

    Not that it matters for this one... but it did look like a rewrite and fix of the original... I didn't even look closely at it.

    This question was more than likely scheduled a month ago - long before the new mandate about images in questions.

    I thought it was quite similar to the first but also noticed that the Select count(*) was changed to a Select *. That change alone eliminates any answer that has a 1 in it, even if you don't understand scope of table variables. 😀

    As far as I remember, the "Select count(*)" was changed by Steve after the discussion on the previous question and originally had a "Select *".

    However, I don't see how does it eliminates the answers with 1 in them.

    I think he meant 0 instead of 1. It does eliminate those answers since the table has only row with a 1 in it. 😉

    _______________________________________________________________

    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/

  • SQLRNNR (8/7/2012)


    Luis Cazares (8/7/2012)


    SQLRNNR (8/7/2012)


    mtassin (8/7/2012)


    And what happened to Steve's statement of NO MORE IMAGES for queries?

    Steve? Come on...

    Not that it matters for this one... but it did look like a rewrite and fix of the original... I didn't even look closely at it.

    This question was more than likely scheduled a month ago - long before the new mandate about images in questions.

    I thought it was quite similar to the first but also noticed that the Select count(*) was changed to a Select *. That change alone eliminates any answer that has a 1 in it, even if you don't understand scope of table variables. 😀

    As far as I remember, the "Select count(*)" was changed by Steve after the discussion on the previous question and originally had a "Select *".

    However, I don't see how does it eliminates the answers with 1 in them.

    Look at the where filter. The only value inserted into the table is 1. The where filter is only selecting the values of 0. None of those queries should return a result set.

    Further proof of the lack of quality for this question. There is so little right and so much wrong with it.

    _______________________________________________________________

    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/

  • Sean Lange (8/7/2012)


    SQLRNNR (8/7/2012)


    Luis Cazares (8/7/2012)


    SQLRNNR (8/7/2012)


    mtassin (8/7/2012)


    And what happened to Steve's statement of NO MORE IMAGES for queries?

    Steve? Come on...

    Not that it matters for this one... but it did look like a rewrite and fix of the original... I didn't even look closely at it.

    This question was more than likely scheduled a month ago - long before the new mandate about images in questions.

    I thought it was quite similar to the first but also noticed that the Select count(*) was changed to a Select *. That change alone eliminates any answer that has a 1 in it, even if you don't understand scope of table variables. 😀

    As far as I remember, the "Select count(*)" was changed by Steve after the discussion on the previous question and originally had a "Select *".

    However, I don't see how does it eliminates the answers with 1 in them.

    Look at the where filter. The only value inserted into the table is 1. The where filter is only selecting the values of 0. None of those queries should return a result set.

    Further proof of the lack of quality for this question. There is so little right and so much wrong with it.

    Agreed.

    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

  • SQLRNNR (8/7/2012)


    Luis Cazares (8/7/2012)


    SQLRNNR (8/7/2012)


    mtassin (8/7/2012)


    And what happened to Steve's statement of NO MORE IMAGES for queries?

    Steve? Come on...

    Not that it matters for this one... but it did look like a rewrite and fix of the original... I didn't even look closely at it.

    This question was more than likely scheduled a month ago - long before the new mandate about images in questions.

    I thought it was quite similar to the first but also noticed that the Select count(*) was changed to a Select *. That change alone eliminates any answer that has a 1 in it, even if you don't understand scope of table variables. 😀

    As far as I remember, the "Select count(*)" was changed by Steve after the discussion on the previous question and originally had a "Select *".

    However, I don't see how does it eliminates the answers with 1 in them.

    Look at the where filter. The only value inserted into the table is 1. The where filter is only selecting the values of 0. None of those queries should return a result set.

    But the queries 1 and 3 have the filter commented (I thought that was the point of the question, but it turned out to be something else).

    The question is wrong in many ways, but at least the answer is correct.

    EDIT: I had the answer's numbers wrong

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares (8/7/2012)


    SQLRNNR (8/7/2012)


    As far as I remember, the "Select count(*)" was changed by Steve after the discussion on the previous question and originally had a "Select *".

    However, I don't see how does it eliminates the answers with 1 in them.

    As I recall the question was how many rows returned... since there's only one row in the table the fact that it's select * or select COUNT(*) doesn't matter.

    There's a lesson on using table variables and scope, but the subject is comments in dynamic SQL and doesn't bother to deal with those as much as it goes after scope.



    --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 (8/7/2012)


    Luis Cazares (8/7/2012)


    SQLRNNR (8/7/2012)


    As far as I remember, the "Select count(*)" was changed by Steve after the discussion on the previous question and originally had a "Select *".

    However, I don't see how does it eliminates the answers with 1 in them.

    As I recall the question was how many rows returned... since there's only one row in the table the fact that it's select * or select COUNT(*) doesn't matter.

    There's a lesson on using table variables and scope, but the subject is comments in dynamic SQL and doesn't bother to deal with those as much as it goes after scope.

    But it does matter if we're talking about number of rows returned.

    With select * you can get either 1 or 0 (in this particular case).

    With select COUNT(*) you'll always get 1 row (showing 1 or 0 for this case).

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares (8/7/2012)


    SQLRNNR (8/7/2012)


    Luis Cazares (8/7/2012)


    SQLRNNR (8/7/2012)


    mtassin (8/7/2012)


    And what happened to Steve's statement of NO MORE IMAGES for queries?

    Steve? Come on...

    Not that it matters for this one... but it did look like a rewrite and fix of the original... I didn't even look closely at it.

    This question was more than likely scheduled a month ago - long before the new mandate about images in questions.

    I thought it was quite similar to the first but also noticed that the Select count(*) was changed to a Select *. That change alone eliminates any answer that has a 1 in it, even if you don't understand scope of table variables. 😀

    As far as I remember, the "Select count(*)" was changed by Steve after the discussion on the previous question and originally had a "Select *".

    However, I don't see how does it eliminates the answers with 1 in them.

    Look at the where filter. The only value inserted into the table is 1. The where filter is only selecting the values of 0. None of those queries should return a result set.

    But the queries 1 and 3 have the filter commented (I thought that was the point of the question, but it turned out to be something else).

    The question is wrong in many ways, but at least the answer is correct.

    EDIT: I had the answer's numbers wrong

    D'oh. I was focused on the scope and neglected that part.

    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

  • And I was focused on that part and neglected the scope. :hehe:

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares (8/7/2012)


    But it does matter if we're talking about number of rows returned.

    With select * you can get either 1 or 0 (in this particular case).

    With select COUNT(*) you'll always get 1 row (showing 1 or 0 for this case).

    Well true... or error, error, error, errror 🙂

    But of course that makes the 1,0,1,0 a possible correct answer because we're talking about select * right?

    Have I mentioned how much I hate this question?



    --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 (8/7/2012)


    Luis Cazares (8/7/2012)


    But it does matter if we're talking about number of rows returned.

    With select * you can get either 1 or 0 (in this particular case).

    With select COUNT(*) you'll always get 1 row (showing 1 or 0 for this case).

    Well true... or error, error, error, errror 🙂

    But of course that makes the 1,0,1,0 a possible correct answer because we're talking about select * right?

    Have I mentioned how much I hate this question?

    Overall - I don't think this is anywhere close to a fan favorite:-D

    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

  • mtassin (8/7/2012)


    Luis Cazares (8/7/2012)


    But it does matter if we're talking about number of rows returned.

    With select * you can get either 1 or 0 (in this particular case).

    With select COUNT(*) you'll always get 1 row (showing 1 or 0 for this case).

    Well true... or error, error, error, errror 🙂

    But of course that makes the 1,0,1,0 a possible correct answer because we're talking about select * right?

    Have I mentioned how much I hate this question?

    I'm sure we all do 😉

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • tommyh (8/6/2012)


    So here i was thinking this was a rewrite of the question we had 2 questions ago, since this question had the varchar(50) on str4 which would have fixed a lot of the issues with the that question. But unfortunatly it wasnt. Instead # had been changed for @.

    Besides what does this actually have to do with "Commenting in Dynamic query"?... nothing i tell you. The comments dont matter. This has more to do with "Scope".

    First question was "interesting" if nothing else. This just bores me. Ah well... keep trying.

    /T

    +1000

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

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

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