In SQL Server 2008 R2, how would I determine what partition a record currently lives in?
Sql-server – Get a record’s current partition
partitioningsql serversql-server-2008-r2
Related Question
- Sql-server – Partition Function Question – DatetimeOffset
- SQL Server – Error in Partition Switching When Migrating from SQL Server 2005 to 2014
- SQL Server – How to Align Data with a Specific Partition
- Sql-server – How to implement composite partition (Range list / Hash range) partition in SQL server
- SQL Server 2016 – Selecting Data with Latest Table Partition That Holds Data
Best Answer
When you can identify a row or set of rows already in the table, you can do it like this:
If you have just a value, and it's not necessarily in the table yet, you can tell what partition it would be in given the current state using
$PARTITION
independently:(This is also useful shorthand if you are identifying the row(s) in the table using the same column.)