SQL Partition

  • Comments posted to this topic are about the item SQL Partition

    Always Think Positive

  • Nice question

    If everything seems to be going well, you have obviously overlooked something.


    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • good question

    Vinay Kumar
    Keep Learning - Keep Growing !!!

  • This quite interesting topic for DW area. Also when the Partition 1 and 4 requires switching? It should fail as partition values are different.

  • This was removed by the editor as SPAM

  • 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):


    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


    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" 🙂

  • Nice question! A reminder on PARTITIONS 🙂

  • Good question and thanks for your findings vk-kirov


  • Very nice question Srikant 🙂

  • I learnt something new today - thanks

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

  • This is a good topic for the question. I think some tweaks to the question as pointed out by vk-kirov could make it a better question.

    Jason...AKA CirqueDeSQLeil
    I have given a name to my pain...MCM SQL Server, MVP
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Thanks for the question. I've never done partition switching before so I learned something new.

  • A good question. I'm not at all sure about the answer though. After answering with my best guess (and getting a probably undeserved point because I picked what I thought was an obvious fail case) I read the referenced article and realised that I knew even less about partitioning than I had thought.


  • good question, but i agree with vk-kirov and SQLRNNR!!!!

    [font="Times New Roman"]rfr.ferrari[/font]
    DBA - SQL Server 2008

    remember is live or suffer twice!
    the period you fastest growing is the most difficult period of your life!
  • I'd love to see an article showing a real world application of switching partitions.

    I understand it would be great for historical data that can be archived by a date field, or year but I've never made any experiences with it before.

    Great question. Thank you.

    Best regards,

    Best regards,

    Andre Guerreiro Neto

    Database Analyst

Viewing 15 posts - 1 through 15 (of 23 total)

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