How to query archived data?

  • Can someone tell me if there's a convenient way to query my archived data in a single query? Let's say I have a table, Rides, and another table RidesArchive, and I want to run a "Select Distinct MemID", or "Select Count(RideID)" from these two tables combined? Can I do it in a single query?  There are numerous more complex queries I would like to run too, but I think that gets the basic point across.

  • Chili,

    I would research UNION in BOL (books online).  This will probably help you.



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Assuming Rides and RidesArchive have the same structure, you could just

    CREATE VIEW RidesAll AS
    SELECT * FROM Rides
    UNION
    SELECT * FROM RidesArchive

    RidesAll is now a view you can query on just like a Rides table.

    Some people might ask why you are archiving data that still gets queried with current data

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

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