I have a table called ‘customer’ which has too many rows & the decision was made to split the table into multiple tables by a date column called InsertedDate. The data span years 2009-2011.
I would like to put each year in its own table. So customers for 2009 go into one table called ‘customer2009’ and so on.
Say I have I have a query like:
SELECT LastName
FROM Customer
WHERE InsertedDate BETWEEN '12/20/2009'
AND '01/15/2010'
Is there a feature in SQL Server (in Enterperise edition ?) where if it gets such a query, it intelligently knows to get the data from different tables. The reason I ask is that I don’t want to modify the query into: (there are hundreds of queries)
SELECT LastName
FROM Customer2009
WHERE InsertedDate >= '12/20/2009'
UNION
SELECT LastName
FROM Customer2010
WHERE InsertedDate <= '01/15/2010'
I would like to read a white paper and best practices and architecture to do this type of thing if a good resource exists.
Addition:
The gist of my question is I wanted to know if there’s a built-in Enterprisy feature in SQL Server. Not to hack a solution manually which needs to be modified and maintained by people.
Look into table partitioning in SQL Server 2005+.