ON [Sales_Partition_Schem]
(Sales_Year)
Insert some values into sales table.
Insert into Sales values ('Pritam Das','2013-06-13',100,2013)
Insert into Sales values ('Pritam Das','2014-06-14',300,2014)
Insert into Sales values ('Pritam Das','2014-08-17',600,2014)
Insert into Sales values ('Pritam Das','2015-06-15',200,2015)
Insert into Sales values ('Pritam Das','2015-08-18',500,2015)
Insert into Sales values ('Pritam Das','2016-06-16',100,2016)
Insert into Sales values ('Pritam Das','2016-08-14',300,2016)
Insert into Sales values ('Pritam Das','2017-06-17',100,2017)
After
Inserting values to sales table, Now is the time to Check for partition.
Select $PARTITION.[Sales_Partition_func](Sales_Year) as P_no,* from Sales
Here we have used Partition function and pass
Partition Key (Sales_Year).
Output:
There are many more
sql Sys table is there to check
partition of table.
To
get the Row count of particular partition you can run below query by change
your partition table name.
Select * from sys.partitions where Object_id in (Select object_id from sys.objects where name='Sales')
Other Partition related SQL Queries.
1. To get the data of particular partition.
Select * from Sales where $PARTITION.[Sales_Partition_func](Sales_Year)=4
1 2. To get the Partition function existing in particular Database and each function
details. Select * from sys.partition_functions
3. see partition range values and Boundary in a particular function.
Select * from sys.Partition_range_values where function_id in (select function_id from sys.partition_functions where name='Sales_Partition_func' )
SELECT * FROM SYS.PARTITION_SCHEMES
SELECT * FROM SYS.DATA_SPACES
SELECT * FROM SYS.DESTINATION_DATA_SPACES
SELECT * FROM SYS.FILEGROUPS