Databases Reference
In-Depth Information
13. Now, verify that the new rows are inserted into proper partitions by executing the
following query:
USE Sample_DB
GO
--Examining Partitions and row count
SELECT
partition_number
,rows
FROM sys.partitions
WHERE object_id = OBJECT_ID('tbl_MyData')
ORDER BY partition_number
14. Observe the result returned by executing the preceding query, as shown in the
following screenshot:
How it works...
In this recipe, by using the
CREATE
PARTITION
FUNCTION
command, we first create a
partition function named
pf_Quaterly_RangeRight
, by specifying the datatype of the
partitioning column (
RecordDateTime
DATETIME
), based upon which the table will be
partitioned. The partition function specifies
RANGE
RIGHT
values
20110101
,
20110401
,
20110701
,
20111001
, and
20120101
. These
RANGE
RIGHT
values specify the boundary
values for each partition, designating each range value as the lowest starting value in the
partitioning column for a partition. By using the
CREATE
PARTITION
SCHEME
command,
we create partition scheme
ps_Quaterly_RangeRight
, to map all partitions to the
PRIMARY
filegroup.
For the sake of simplicity in this example, we used the
PRIMARY
filegroup
for all partitions. However, in production environments, it is recommended to
place your partitions in different locations by specifying different filegroups.
Search WWH ::
Custom Search