Moving a clustered Primary Key to a new filegroup online

It is not an unusual requirement for a DBA to have to move a table to new storage. A simple way to do this is to create a new filegroup with the appropriate number of files and rebuild the indexes on the new filegroup. If you are lucky enough to run Enterprise Edition, this can even be done online. But what if you have to deal with a constraint, like a clustered Primary Key? Perhaps due to the scripting options in SQL Server Management Studio, most DBAs will drop and recreate the constraint like below.

However, you can in fact move the clustered Primary Key in an online fashion using the syntax below. Even though we are specifying a unique clustered index, SQL server will still honor the Primary Key constraint.

Note that this method only works provided you are not changing the definition of the Primary Key (including column order).