• Good question, but the answer is totally wrong. The ALTER TABLE statement fails at least for two reasons (and both of these reasons are available at the link given in the explanation):

    1)

    General Requirements for Switching Partitions

    Both the source and the target of the ALTER TABLE...SWITCH statement must reside in the same filegroup, and their large-value columns must be stored in the same filegroup.

    Thus, after running the ALTER TABLE statement we'll see the following error message:

    ALTER TABLE SWITCH statement failed. Partition 1 of table 'test_db.dbo.trx' is in filegroup 'fg1' and partition 4 of table 'test_db.dbo.trx_hy' is in filegroup 'fg4'.

    2) Let's assume that both partitions reside in the same filegroup.

    Constraint Requirements

    If you are switching a partition of a partitioned table to another partitioned table, the boundary values of the source partition must fit within the boundary values of the target partition.

    Let's create the tables on the following partition scheme:

    create partition scheme ps1

    as

    partition pf1 to ([primary], [primary], [primary], [primary]);

    After running the ALTER TABLE statement we'll see the following error message:

    ALTER TABLE SWITCH statement failed. Range defined by partition 1 in table 'test_db.dbo.trx' is not a subset of range defined by partition 4 in table 'test_db.dbo.trx_hy'.

    So, the correct answer should be "The statement always fails" 🙂