SQL Server Performance

moving table from one filegroup to another file group in sqlserver 2005

Discussion in 'SQL Server 2005 General DBA Questions' started by priyaram, Mar 18, 2008.

  1. priyaram New Member

    hi,
    in our sqlserver 2005 , there is an database called " ta-prod' and there is an object name "dbo.dx_customer" which is on the index file group and also there are lot of dependencies for that table.and i want to move that object to "PRIMARY" file group from "INDEX" file group..
    also the table contains 500000 rows...how can i do that...
    thanks
  2. SQLDBcontrol New Member

    Hi. You need to drop the primary key constraint, and use the MOVE TO option. Once that has finished you have to rebuild the primary key constraint, at which point you can specifiy either of the filegroups (you might want to build it on the index file group) or let it get created on the default file group.
    ALTER TABLE dbo.dx_customer DROP CONSTRAINT <primary key> WITH (MOVE TO PRIMARY);
    GO
    ALTER TABLE dbo.dx_customer ADD CONSTRAINT <primary key> PRIMARY KEY(<primary key column>);
    GO

Share This Page