CROSS APPLY on named sets

  • MMartin1

    One Orange Chip

    Points: 27488

    Comments posted to this topic are about the item CROSS APPLY on named sets

    ----------------------------------------------------
    How to post forum questions to get the best help [/url]

  • SQLRNNR

    SSC Guru

    Points: 281210

    I dunno about the "correct" answer on this one. The statements compile for me but produce an error at run-time. Seems to be a bit of a mixup here.

    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

  • Eirikur Eiriksson

    SSC Guru

    Points: 182356

    SQLRNNR (1/12/2016)


    I dunno about the "correct" answer on this one. The statements compile for me but produce an error at run-time. Seems to be a bit of a mixup here.

    What version of SQL Server? It fails the compilation on 2008,2008R2,2012 and 2014.

    😎

  • This was removed by the editor as SPAM

  • morlindk

    SSCrazy

    Points: 2294

    Phew.., I got the two points for the answer - but can't say I got the point of the question, even reading the outline. - Lucky though, to keep my streak alive: Tomorrow it is either one full month since mid-december, or devastation.

  • tripleAxe

    SSCertifiable

    Points: 5523

    The T-SQL parses OK but does not compile. A lesson re-learnt this morning for me; the difference between parse and compile. 🙂

  • david.dilworth

    Right there with Babe

    Points: 780

    I think it's the difference between "parse" and "compile" that is causing the confusion here.

  • Carlo Romagnano

    SSC-Insane

    Points: 21795

    I disagree with explanation, the error generated

    Msg 4104, Level 16, State 1, Line 2

    The multi-part identifier "o.object_id" could not be bound.

    it's not caused by CROSS APPLY, but a reference to a column not yet linked.

    These examples generate the same error:

    SELECT s1.c1, o.object_id

    FROM (values (o.object_id+2)) s1(c1)

    CROSS JOIN sys.objects o

    or

    SELECT s1.c1, o.object_id

    FROM (values (o.object_id+2)) s1(c1)

    JOIN sys.objects o on 1=1

  • anilkpadule

    Valued Member

    Points: 63

    This is what I got 🙂

    c1 c1

    7 7

    7 8

    7 9

  • edwardwill

    SSCarpal Tunnel

    Points: 4907

    Eirikur Eiriksson (1/12/2016)


    SQLRNNR (1/12/2016)


    I dunno about the "correct" answer on this one. The statements compile for me but produce an error at run-time. Seems to be a bit of a mixup here.

    What version of SQL Server? It fails the compilation on 2008,2008R2,2012 and 2014.

    😎

    I can't find any option to compile a query. Parse, yes (the query parses). Execute, yes (the query fails - "The multi-part identifier "s2.c1" could not be bound.") But compile?

  • Jacob Wilkins

    One Orange Chip

    Points: 27727

    edwardwill (1/13/2016)


    Eirikur Eiriksson (1/12/2016)


    SQLRNNR (1/12/2016)


    I dunno about the "correct" answer on this one. The statements compile for me but produce an error at run-time. Seems to be a bit of a mixup here.

    What version of SQL Server? It fails the compilation on 2008,2008R2,2012 and 2014.

    😎

    I can't find any option to compile a query. Parse, yes (the query parses). Execute, yes (the query fails - "The multi-part identifier "s2.c1" could not be bound.") But compile?

    Generate the estimated execution plan 🙂

  • edwardwill

    SSCarpal Tunnel

    Points: 4907

    Jacob Wilkins (1/13/2016)


    edwardwill (1/13/2016)


    Eirikur Eiriksson (1/12/2016)


    SQLRNNR (1/12/2016)


    I dunno about the "correct" answer on this one. The statements compile for me but produce an error at run-time. Seems to be a bit of a mixup here.

    What version of SQL Server? It fails the compilation on 2008,2008R2,2012 and 2014.

    😎

    I can't find any option to compile a query. Parse, yes (the query parses). Execute, yes (the query fails - "The multi-part identifier "s2.c1" could not be bound.") But compile?

    Generate the estimated execution plan 🙂

    I did that. No compilation errors reported.

  • Jacob Wilkins

    One Orange Chip

    Points: 27727

    edwardwill (1/13/2016)


    Jacob Wilkins (1/13/2016)


    edwardwill (1/13/2016)


    Eirikur Eiriksson (1/12/2016)


    SQLRNNR (1/12/2016)


    I dunno about the "correct" answer on this one. The statements compile for me but produce an error at run-time. Seems to be a bit of a mixup here.

    What version of SQL Server? It fails the compilation on 2008,2008R2,2012 and 2014.

    😎

    I can't find any option to compile a query. Parse, yes (the query parses). Execute, yes (the query fails - "The multi-part identifier "s2.c1" could not be bound.") But compile?

    Generate the estimated execution plan 🙂

    I did that. No compilation errors reported.

    Hmmm...generates an error for me.

  • Rich Mechaber

    SSChampion

    Points: 10935

    SQLRNNR (1/12/2016)


    I dunno about the "correct" answer on this one. The statements compile for me but produce an error at run-time. Seems to be a bit of a mixup here.

    +1

  • edwardwill

    SSCarpal Tunnel

    Points: 4907

    See attachment.

    Edward

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

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