T-SQL

  • SSSolice

    SSCommitted

    Points: 1907

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

  • SQLRNNR

    SSC Guru

    Points: 281243

    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

  • brdudley

    SSCrazy

    Points: 2288

    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.

  • BudaCli

    Hall of Fame

    Points: 3383

    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
  • optradba

    Right there with Babe

    Points: 732

    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? 🙂

  • Chris Hamam

    SSC-Addicted

    Points: 444

    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)

  • Christian Buettner-167247

    SSChampion

    Points: 13729

    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

  • chriscoates

    Mr or Mrs. 500

    Points: 520

    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

  • Muhammad Haseeb Farhan

    Right there with Babe

    Points: 728

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

  • chenthilar

    SSC Enthusiast

    Points: 119

    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

  • Bhavesh_Patel

    SSCrazy

    Points: 2259

    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/
  • Julie Hargraves

    SSCarpal Tunnel

    Points: 4457

    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.

  • Noel McKinney

    Hall of Fame

    Points: 3385

    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

  • Dave62

    SSCertifiable

    Points: 6664

    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 48 total)

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