T-SQL

  • Somehow I had the feeling this question would have a controversial "correct" answer because it was just too obvious that it should be "Operator".

  • As one who has been beaten from pillar to post during the discussion of QOD's that I have submitted and which where published ... I am sorry to say that I do not think the author of this QOD performed due diligence in their search for the justification of the supposed correct answer.

    But my thoughts do not change the outcome, the only individual empowered to do that is Steve Jones.

    Hence let's ask Steve Jones to ajudicate.

    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]

  • hai

  • Dave62 (1/7/2010)


    I can understand the confusion with this question since msdn refers to IN many different ways. A number of msdn links have already been posted to defend different answers and here is another one.

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

    In the remarks section the first sentence refers to IN as a clause. "...values (many thousands) in an IN clause can..."

    Also, the article referenced is specifically for IN (Transact-SQL) not predicates or logical operators.

    Dave

    Well yet another term - see here for details with regards to the "logical" IN clause.

    http://www.articleworld.org/index.php/Clause_%28logic%29

    Edit: Just to provide an example, the IN clause in predicate

    Edit2: added operator to IN clause

    fieldx IN (1,2,3)

    is

    IN (1,2,3)

    Not to mix up with "grammar" clauses like the SELECT or FROM clause.

    Best Regards,

    Chris Büttner

  • This QOD actually has 2 answers that are correct, and should reflect such.

    The "IN" statement can be used as both a predicate and an operator. See BOL:

    Logical Operator

    IN - TRUE if the operand is equal to one of a list of expressions.

    Predicate:

    Is an expression that evaluates to TRUE, FALSE, or UNKNOWN. Predicates are used in the search condition of WHERE clauses and HAVING clauses, the join conditions of FROM clauses, and other constructs where a Boolean value is required.

    Thus, with the answers set up the way that they are, with only one answer being selectable, we should get credit for either answer being correct.

    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

  • I am with those who want points for picking "Operator." This is merely anecdotal, but I visualized replacing IN with = or > and it seems like they all serve the same type of purpose - to compare values on either side.

    Or to phrase my point-grubbing in SQL befitting the QOTD:

    INSERT INTO webrunner_account (QOTD_Points)

    SELECT Points

    FROM Question

    WHERE Question = 'T-SQL/68500/'

    AND Answer IN ('Predicate','Operator')

    Or something like that. 🙂

    - webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • Good question. I thought its an operator. But, after some googling found though it could be called an operator but would be considered in Predicate.

    Predicate (Transact-SQL)

    Is an expression that evaluates to TRUE, FALSE, or UNKNOWN. Predicates are used in the search condition of WHERE clauses and HAVING clauses, the join conditions of FROM clauses, and other constructs where a Boolean value is required.

    SQL DBA.

  • Sorry, but "IN" standalone is not a predicate, especially in the case where you have to decide between answers operator and predicate. Explanations (and distinctions between the terms) were given above - please take the time to read them carefully.

    Best Regards,

    Chris Büttner

  • CB - You are correct, but the question generically asked what the "IN" is considered in a T-SQL statement. There were no examples or conditions qualifying the question.

    Based upon that, the answer would have to be either predicate or operator.

    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

  • Well W3 considers it an operator.

    http://www.w3schools.com/sql/sql_in.asp

    But I could also see the case that you have an IN clause with the IN operator and the results of that clause are the IN predicate.



    --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]

  • I see both sides in this argument. BOL is inconsistent and I have added feedback to that note to various links to have this clarified at the source we use. When I got the QOD and followed the link, Predicate seemed correct. However the more I look at the wording, I can see where operator is a valid argument. My first thought was operator as well, but then I thought it's in the WHERE clause, so predicate made sense.

    I have changed the question to include "in (z, y, z, ...)" as the "what is this" portion, which should clear up confusion as to this being a predicate.

    I will award back all points to date to people once my password gets reset 🙂 Forgot it over the holidays. :hehe:

  • Hm this is still not correct - and even more important - I made an error myself - the IN clause is not only the list of values, it also includes the operator itself.

    Example:

    columna IN (1,2,3)

    Predicate:

    columna IN (1,2,3)

    IN (logical) clause:

    IN (1,2,3)

    IN operator:

    IN

    Best Regards,

    Chris Büttner

  • Ok, my turn now. I answered operator as well and got it wrong. Being the first one to respond to the thread - I didn't want to beat the author up (and give away the answer too soon) over it. I was trying to play nicely since he had gumption to submit a QOD in the first place.

    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

  • good point, Christian. I've added in the column to the question.

  • Think this would have been a better question if it had been multiple checkboxes.

    Kind of like

    + is a

    A. Addition Operator

    B. Concatenation Operator

    C. Mathematical Symbol

    D. The fifth letter of the English alphabet

    And only letting you pick one answer. 😉



    --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]

Viewing 15 posts - 16 through 30 (of 48 total)

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