Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Changning filegroup for a table

Author  Topic 

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2004-01-08 : 06:44:20
How to change the file group of a table using T-sql.

Thank you.

------------------------
I think, therefore I am

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-01-08 : 07:59:53
I think there's another way (I just can't remember it right now), but you can always drop and recreate (or just create) the table's clustered index on the new filegroup. If the primary key or a unique constraint is clustered, you'll need to use ALTER TABLE...DROP CONSTRAINT and then add the constraint back:

ALTER TABLE myTable DROP CONSTRAINT PK_MyTable
ALTER TABLE myTable ADD CONSTRAINT PK_MyTable PRIMARY KEY CLUSTERED(col1) ON [NewFileGroup]
Go to Top of Page

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2004-01-08 : 08:34:01
Thank You.
Is there a way to move tables not having clustered index?

------------------------
I think, therefore I am
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-01-08 : 09:04:21
Don't think so.
You will have to add the clustered index then drop it.

Given the work that will have to be done it is probably easier (and quicker) to bcp the table out and in again.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-01-08 : 12:49:05
Just a little thread theft question.

Is there any perf gains by having mult files on the sam disk?



Brett

8-)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-01-08 : 12:51:09
Never done it, but... Having a separate disk is not enough. You have to have a separate disk controller for each in order to get the most benefits.

Tara
Go to Top of Page
   

- Advertisement -