Error while using SWITCH command

  • Getting following error while using following switch command.

    ------

    ALTER TABLE

    Transac_Archive_Stage

    SWITCH TO

    Transac_Archive PARTITION 6

    GO

    Msg 4972, Level 16, State 1, Line 1

    ALTER TABLE SWITCH statement failed. Check constraints or partition function of source table 'IDX.dbo.Transac_Archive_Stage' allows values that are not allowed by check constraints or partition function on target table 'IDX.dbo.Transac_Archive'.

  • balbirsinghsodhi (10/7/2009)


    Getting following error while using following switch command.

    ------

    ALTER TABLE

    Transac_Archive_Stage

    SWITCH TO

    Transac_Archive PARTITION 6

    GO

    Msg 4972, Level 16, State 1, Line 1

    ALTER TABLE SWITCH statement failed. Check constraints or partition function of source table 'IDX.dbo.Transac_Archive_Stage' allows values that are not allowed by check constraints or partition function on target table 'IDX.dbo.Transac_Archive'.

    You have to alter your check constraints to not allow those values which i believe are nulls.

    Google "ALTER TABLE SWITCH statement failed. Check constraints or partition function of source table"

    and see how others have fixed this mistake.

    Alex S
  • Thanks for the reply Alex.

    I checked the constraint and all are correct.

    I also add NOT NULL in the check constraint but still getting the same error. Don't know what is wrong.

    There is no null values in the partition field.

    I googled and everybody mentioned the same things, add NOT NULL in the check constraint.

    If you want, I can explain in more detail.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply