Can't repartition SQL Server table due to missing "next used filegroup"?

I’m running an application job which works with a SQL Server database and getting the following error:

The partition scheme '<partition_scheme_name>' does not have any next used filegroup.

I’ve tried running the following command to resolve the issue, however, it didn’t work:

ALTER PARTITION SCHEME [dbo.partition_scheme_name]   
NEXT USED [PRIMARY];

Has anyone encountered this issue before and found a successful solution?

This error occurs when the partition scheme doesn’t have a next used filegroup specified. To resolve this error, you need to specify the next used filegroup in the partition scheme.

Here’s an example command you can use:

ALTER PARTITION SCHEME [partition_scheme_name] NEXT USED [filegroup_name];

Make sure to replace partition_scheme_name with the name of your partition scheme and filegroup_name with the name of the filegroup you want to use as the next used filegroup.