Question

I don't know if this is even possible but we are looking to create a partition function in SQL Server 2008 that would allow us to partition a table on a state abbreviation key column (i.e. 'FL','AZ',.. etc). In essence we would have 50 partitions. I understand that the way partition functions are setup is through left or right values but that is not what we need so was wondering if our scenario would be possible. Thanks everybody.

Was it helpful?

Solution

Ranges should work quite ok for the problem, as long as there is a single state per range. This can be achieved using a LEFT range with the values listed in alphabetical order.

If required, you could also add a check constraint to limit the values to valid state names;

CREATE PARTITION FUNCTION bop (CHAR(2)) AS
  RANGE LEFT FOR VALUES('AK', 'AL', 'AR', 'AZ', ...)
END;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top