T-SQL

  • Comments posted to this topic are about the item T-SQL

  • Thanks for the question

    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

  • This help page lists the logical operators (http://msdn.microsoft.com/en-us/library/ms189773(SQL.90).aspx) including IN.

    I don't doubt that an entire clause containing IN is a predicate, but perhaps IN is the operator in the predicate.

  • Also thaught that a logical operator is correct but a lil explanation will be more apreciated from this side.

    What you don't know won't hurt you but what you know will make you plan to know better
  • BOL says that IN is a logical operator. Can you please explain why you considered it as a Predicate? Since most of us answered it "wrong", I think we deserved an explanation, right? 🙂

  • brdudley (1/7/2010)


    This help page lists the logical operators (http://msdn.microsoft.com/en-us/library/ms189773(SQL.90).aspx) including IN.

    I don't doubt that an entire clause containing IN is a predicate, but perhaps IN is the operator in the predicate.

    I agree - IN is technically the logical operator that exists within an expression, which then creates a predicate.

    IN by itself certainly does not return anything at all - neither TRUE, nor FALSE, nor UNKNOWN - it would be a syntax error if that was used on it's own.

    <predicate> ::=

    { expression { = | < > | ! = | > | > = | ! > | < | < = | ! < } expression

    | string_expression [ NOT ] LIKE string_expression

    [ ESCAPE 'escape_character' ]

    | expression [ NOT ] BETWEEN expression AND expression

    | expression IS [ NOT ] NULL

    | CONTAINS

    ( { column | * } , '< contains_search_condition >' )

    | FREETEXT ( { column | * } , 'freetext_string' )

    | expression [ NOT ] IN ( subquery | expression [ ,...n ] )

    | expression { = | < > | ! = | > | > = | ! > | < | < = | ! < }

    { ALL | SOME | ANY} ( subquery )

    | EXISTS ( subquery ) }

    Source:

    http://msdn.microsoft.com/en-us/library/ms173545%28SQL.90%29.aspx

    --Chris Hamam

    Life's a beach, then you DIE (Do It Eternally)

  • I agree that the given answer is wrong.

    IN is an operator but can be used in an expression like "a IN (1,2,3)".

    The expression in this case is a predicate, and IN is the operator used in the predicate.

    Best Regards,

    Chris Büttner

  • This was removed by the editor as SPAM

  • I agree with the previous posts. A little more justification for the answer please.

    Also, I'm sure that I've seen my execution plans change

    WHERE colA IN(1)

    into

    WHERE colA=1

    and

    WHERE colA IN(1,2,3)

    into

    WHERE colA=1 OR colA=2 OR colA=3

    Though to be honest, I can't replicate that right now. I might have seen it running a trace at some point.

    It does highlight how SQL tests a value in 2 columns though:

    WHERE 1 in(colA,colB)

    turns into

    WHERE 1=colA OR 1=colB

  • Agree with Christian Buettner ... IN is the operator used in the predicate.

  • Answer is : Operator

    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.

    IN is the logical operator

    Please visit the below one to know all the logical operator

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

  • I answered 'Operator' - And guess what, I got it wrong. :w00t:

    I agree with all the above members, 'IN' is an operator.



    [font="System"]Bhavesh Patel[/font]

    http://bhaveshgpatel.wordpress.com/
  • Allow me to jump on the bandwagon here and say that 'IN' by itself is a logical operator. 'SomeField IN ( 1, 2, 3 )' would be considered a predicate, but by itself, 'IN' does not evaluate to TRUE, FALSE, or UNKNOWN.

  • I'll chime in as well to say that IN is an operator. See BOL for list of Logical Operators

    http://msdn.microsoft.com/en-us/library/ms189773(SQL.90).aspx

  • 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

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

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