Friday, March 23, 2012

Moving Tables

I'm aware of the two methods of moving a table from one filegroup to another
:
(re)create a clustered index on the new filegroup or create the table on the
new filegroup then bcp data into new table.
Is there just a simple way to say "move from PRIMARY to whatever"?
Thanks!!Hi,
Easiest method is to re-create the clustered index in new file group. This
will move the table to the new file group automatically.
Enterprise Manager moves a table from one filegroup to another without using
an undocumented task, but T-SQL doesn't have a command that does the same
thing. The easiest way to move a table to another filegroup is to create a
clustered index on the table. If the table already has a clustered index,
you can use the CREATE INDEX command's WITH DROP_EXISTING clause to recreate
the clustered index and move it to a particular filegroup. When a table has
a clustered index, the leaf level of the index and the data pages of the
table essentially become one and the same. The table must exist where the
clustered index exists, so if you create or recreate a clustered
index-placing the index on a particular filegroup-you're moving the table to
the new filegroup as well.
Thanks
Hari
SQL Server MVP
"A. Robinson" <ARobinson@.discussions.microsoft.com> wrote in message
news:D6A7F27B-309D-40C1-9663-D28B2514673A@.microsoft.com...
> I'm aware of the two methods of moving a table from one filegroup to
> another:
> (re)create a clustered index on the new filegroup or create the table on
> the
> new filegroup then bcp data into new table.
> Is there just a simple way to say "move from PRIMARY to whatever"?
> Thanks!!
>|||I was kinda afraid of that...that's the way I've done it in the past.
Thanks!
What aboutr setting a filgroup to read only - through the gui only'
"Hari Pra" wrote:

> Hi,
> Easiest method is to re-create the clustered index in new file group. This
> will move the table to the new file group automatically.
> Enterprise Manager moves a table from one filegroup to another without usi
ng
> an undocumented task, but T-SQL doesn't have a command that does the same
> thing. The easiest way to move a table to another filegroup is to create a
> clustered index on the table. If the table already has a clustered index,
> you can use the CREATE INDEX command's WITH DROP_EXISTING clause to recrea
te
> the clustered index and move it to a particular filegroup. When a table ha
s
> a clustered index, the leaf level of the index and the data pages of the
> table essentially become one and the same. The table must exist where the
> clustered index exists, so if you create or recreate a clustered
> index-placing the index on a particular filegroup-you're moving the table
to
> the new filegroup as well.
> Thanks
> Hari
> SQL Server MVP
> "A. Robinson" <ARobinson@.discussions.microsoft.com> wrote in message
> news:D6A7F27B-309D-40C1-9663-D28B2514673A@.microsoft.com...
>
>|||Hi,
I have moved the table to different file group couple of times. But ensure
that you take a full database backup before doing this.
I have never tried setting a file group to read only from GUI, but i did
once using TSQL. But i belive to set the file group to read only first you
need to set the database to SINGLE USER Mode.
Thanks
Hari
SQL Server MVP
"A. Robinson" <ARobinson@.discussions.microsoft.com> wrote in message
news:3613F67F-6AE7-4A5A-987D-85C5269675F1@.microsoft.com...
>I was kinda afraid of that...that's the way I've done it in the past.
> Thanks!
> What aboutr setting a filgroup to read only - through the gui only'
> "Hari Pra" wrote:
>

No comments:

Post a Comment