use test
select  
	t.name as TableName  , 
	ps.name as PartitionScheme  , 
	pf.name as PartitionFunction  , 
	p.partition_number  , 
	p.rows  , 
	case    
		when pf.boundary_value_on_right=1 then 'RIGHT'    
		else 'LEFT'    
	end [range_type]  , 
	prv.value [boundary]
from sys.tables t    
	join sys.indexes i on t.object_id = i.object_id    
	left join sys.partition_schemes ps on i.data_space_id = ps.data_space_id    
	left join sys.partition_functions pf on ps.function_id = pf.function_id    
	join sys.partitions p on i.object_id = p.object_id and i.index_id = p.index_id    
	left join sys.partition_range_values prv on pf.function_id = prv.function_id and p.partition_number = prv.boundary_id
where i.index_id < 2  --So we're only looking at a clustered index or heap, which the table is partitioned onorder by p.partition_number
	and OBJECT_NAME(t.object_id)  = 'orders'
order by TableName,partition_number
