August 1, 2012 at 1:48 pm
I need to implement something similar to this:
http://www.sqlservercentral.com/articles/Partitioning/71655/
However, there are some differences between that article, and what I need to implement.
These are:
1.) I need this done for a single table.
2.) I need each partition to be for a year, rather than a month.
3.) I don't want any data removed, so I don't need what happens in part III at all.
4.) I don't want to use PowerShell, I just want pure T-SQL with agent jobs.
Can anyone help or point me in the right direction?
August 1, 2012 at 1:55 pm
1.) I need this done for a single table.
A Partition function and scheme are not table specific, the table is built on the scheme. So if you have more than 1 table built on this scheme, you cannot do it for only 1 table.
2.) I need each partition to be for a year, rather than a month.
Then you create your function based on years and not on months.
3.) I don't want any data removed, so I don't need what happens in part III at all.
Don't do part III. Simply merge that partition in with the left partition.
4.) I don't want to use PowerShell, I just want pure T-SQL with agent jobs.
Write the job in SQL.
Try this:http://msdn.microsoft.com/en-us/library/aa964122%28v=sql.90%29.aspx
If this is a question on how to partition and how to write your functions and such... Best to give it a try first and post any specific issues with proper DDL.
Jared
CE - Microsoft
August 2, 2012 at 8:04 am
I like that article, it looks just like what I need.
I'll study it, and use it as a baseline to write similar code without getting rid of any data.
Then, I'll post that and let you see if you think it will work.
Of course I'll test it in my dev environment, but any help or advice is appreciated as this is my first forey into SQL partitioning.
August 2, 2012 at 8:18 am
The key here is to keep your storage aligned. We'll be here to help on specifics 🙂 Good luck!
Jared
CE - Microsoft
August 2, 2012 at 8:51 am
Ok, 1 quick question.
So, I want to modify the partition function to be based on years...but is it really as simple as turning this:
create partition function pfDaily (datetime)
as RANGE RIGHT for values(
'2005-05-07', '2005-05-08', '2005-05-09', '2005-05-10', '2005-05-11', '2005-05-12', '2005-05-13', '2005-05-14',
'2005-05-15', '2005-05-16', '2005-05-17', '2005-05-18', '2005-05-19', '2005-05-20', '2005-05-21', '2005-05-22',
'2005-05-23', '2005-05-24', '2005-05-25', '2005-05-26', '2005-05-27', '2005-05-28', '2005-05-29', '2005-05-30',
'2005-05-31', '2005-06-01', '2005-06-02', '2005-06-03', '2005-06-04', '2005-06-05', '2005-06-06', '2005-06-07',
'2005-06-08', '2005-06-09', '2005-06-10', '2005-06-11', '2005-06-12', '2005-06-13', '2005-06-14', '2005-06-15',
'2005-06-16', '2005-06-17', '2005-06-18', '2005-06-19', '2005-06-20', '2005-06-21', '2005-06-22', '2005-06-23',
'2005-06-24', '2005-06-25', '2005-06-26', '2005-06-27', '2005-06-28', '2005-06-29', '2005-06-30', '2005-07-01',
'2005-07-02', '2005-07-03', '2005-07-04')
and making it this:
create partition function pfDaily (datetime)
as RANGE RIGHT for values(
'2005-10-01', '2006-10-01', '2007-10-01', '2008-10-01', '2009-10-01', '2010-10-01', '2011-10-01', '2012-10-01')
What I'm trying to do here is to create a seperare partition for each year, and I'm defining a year as 10-01-XXXX through 9-31-XXXX.
Does that make sense?
August 2, 2012 at 8:53 am
That's all there is to it!
Jared
CE - Microsoft
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply