Alter table switch partition to another filegroup of another table

sakuraime 2,341 Reputation points
2020-11-06T10:49:35.543+00:00

Is it possible to use "Alter table switch partition......." to move the partition to another other table which in different filegroup from the source table ?

SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Guoxiong 8,206 Reputation points
    2020-11-07T00:39:11.613+00:00

    You cannot directly switch a partition from the partitioned table to a table in a different file group, but you can do it indirectly.

    1. Create a table (named SourceTemp) with the same structure as the partitioned table on the same filegroup
    2. Switch the partition from the partitioned table to the table SourceTemp on the same filegroup
    3. Export data from the table SourceTemp to the destination table on another file group.
    4. Drop the table SourceTemp
    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2020-11-06T23:07:49.417+00:00

    If you read the topic for ALTER TABLE, you will find this sentence: Both the source table or partition, and the target table or partition, must be located in the same filegroup.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.