Finding Partition Boundaries

Kenneth Fisher shows how to find the min and max values for a partition:

So what does it do? Per BOL

Returns the partition number into which a set of partitioning column values would be mapped for any specified partition function in SQL Server 2016.

So it basically tells us which partition any given row is in. This can be particularly handy at times. For example, if you want to know the min and max values of a column per partition.

Read on for a couple scripts which use $Partition.

Related Posts

Performance Comparison: Comparing Column Differences

Shane O’Neill has a column difference showdown: The original post for this topic garnered the attention of a commenter who pointed out that the same result could be gathered using a couple of UNION ALLs and those lovely set-based EXCEPT and INTERSECT keywords. I personally think that both options work and whatever you feel comfortable […]

Read More

Interesting SQL Server GitHub Repos

Denis Gobo links to five interesting GitHub repos: dbatools dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included. GitHub Repo is here: https://github.com/sqlcollaborative/dbatools Also make sure to visit their website: https://dbatools.io/ Read on for the other four.

Read More

Categories