![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
I want to define query (maybe view, procedure): select * from [???] where date>='2007-01-01' and date<='2007-04-30' |
|
Hi there, I have tables with such structure transaction_YYMM (idx,date,company_id,value) where YYMM stands for 2digits year and month I want to define query (maybe view, procedure): select * from [???] where date>='2007-01-01' and date<='2007-04-30' which will grab data from transaction_0701 transaction_0702 transaction_0703 transaction_0704 and return all as one best regards Rafal |
#2
| |||
| |||
|
|
A UNION ALL query will combine multiple result sets: SELECT * FROM dbo.transaction_0701 UNION ALL SELECT * FROM dbo.transaction_0702 UNION ALL SELECT * FROM dbo.transaction_0703 UNION ALL SELECT * FROM dbo.transaction_0704 You can specify an explicit column list (a Best Practice) and encapsulate the query in a view to facilitate reuse. You might also consider creating a partitioned view (or a partitioned table if you are running SQL 2005 Enterprise Edition). See the Books Online for more information. |
#3
| |||
| |||
|
|
I have tables with such structure transaction_YYMM (idx,date,company_id,value) where YYMM stands for 2digits year and month I want to define query (maybe view, procedure): select * from [???] where date>='2007-01-01' and date<='2007-04-30' which will grab data from transaction_0701 transaction_0702 transaction_0703 transaction_0704 and return all as one |
![]() |
| Thread Tools | |
| Display Modes | |
| |