"DERIVEDTBL" ?

  • When I build a UNION query in Enterprise Manager, it tags on the "DERIVEDTBL" after my final UNION. What is the importance of this command? I can find nothing on it in the documentation, and even a search across Google.com & usenet brings up an amazingly small number of hits.

    Anyone? I find that if I build a query in Query Analyzer with it or without it, I get the same results.

    - Tom

  • I saw this today in Access as well for a subquery.

    Don't "build" queries. Write them.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • Dont remember seeing it. It's just an alias for the final select, which is really a 'derived table'. I don't use the graphical tools often, but sometimes they are timesavers. Steve is old school you know!

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • Okay, righto, that makes sense now. If the actual query I wrote was like so...

    SELECT TOP 100 PERCENT *

    FROM (

    SELECT *

    FROM Table_1

    UNION

    SELECT *

    FROM Table_2

    )

    ...then the Enterprise Manager would tag on "DERIVEDTBL" at the end. But if I provided my own alias, it used that instead. So...call me Slaphead, it's pretty clear now what it was doing.

    And Steve, point well taken. I generally don't "build" them using graphical tools. And as such tools go, I really don't like Enterprise Manager anyway. I was using the term generically -- as where I said "I find that if I build a query in Query Analyzer..."

    - Tom

Viewing 4 posts - 1 through 3 (of 3 total)

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