One other thing, it doesn't work on tables partitioned on columns of any other data type than int. For example, my partition column is of datetime. The script fails right from the start where it verifies if the partition table, schema or partition number exists:
-- need exact match
AND cast(rv.value as int)=@partitionValue
I will modify the script to fit my case, but you can modify the procedure so you can pass the data type of the partitioned column as well.
And btw.... nice job man!!
It saved me at least 2 days of figuring it out on myself!