December 14, 2005 at 11:53 pm
I have to get data for a set of columns every month from 30 different tables. The data is to be stored datewise. The data are stored in a particular table named -- 'lonYYYYMMDD' where YYYYMMDD stands for the date to which the data pertains to.
My job is to get data in the following format:
Date
December 15, 2005 at 4:06 am
That sound like a pretty insane table design. What's wrong with storing all the data in one table with a date column?
That said... The union statement (and union all) is your friend here
SELECT <columns> FROM TableForDateA
UNION ALL
SELECT <columns> FROM TableForDateB
UNION ALL
SELECT <columns> FROM TableForDateC
...
Look up Union in Books online for the specifics of how it works. If you need more help, please post your table design, sample data and required output.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply