Answered SQL 2008 Move a table to a specific file in a different filegroup

  • 2 พฤษภาคม 2555 21:23
     
     

    Hi everyone,

    I need to move a large table to a new file group which has 3 files in it and each file is situated to a differed HDD. I tested the following statement:

    CREATE CLUSTERED INDEX CIX_YourTable
      
    ON dbo.YourTable(YourClusteringKeyFields)
      
    WITH DROP_EXISTING
      
    ON [filegroup_name]


    The problem I faced is that my data got transfered between the three files in my filegroup. I need to transfer my table to a specific file within the file group.

    How can I achieve this.

    Thank you in advance

    • เปลี่ยนแปลงประเภท Tom PhillipsModerator 2 พฤษภาคม 2555 21:58
    •  

ตอบทั้งหมด

  • 2 พฤษภาคม 2555 21:59
    ผู้ดูแล
     
     คำตอบ

    Short answer, you can't.

    Objects exist on a filegroup , not a file.  The only way to do what you describe is to create a filegroup with only 1 file and transfer the object to that filegroup.

    • เสนอเป็นคำตอบโดย Sankar ReddyModerator 2 พฤษภาคม 2555 22:12
    • ทำเครื่องหมายเป็นคำตอบโดย Stephanie LvModerator 14 พฤษภาคม 2555 8:22
    •  
  • 3 พฤษภาคม 2555 13:32
     
     

    Whats been said above is true but in case you are keen for a specific file in that group this is what you may try.

    Disable auto increment for the other file but not for your selected one. Now do what you usually do to relocate in the file groups.

    Do Note.

    Dynamics will change as you add / remove / modify rows, balancing the free space in the other files.


    yup