var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Change Table's FileGroup
I would like change table's filegroup.
How can I do by script?
I think you may have to create a new table in different filegroup, and transfer the data to this new table and create all the relationships. Then
finally drop the old table and rename the new table to the old one.
Anybody has better way?
The only way of doing this (of which I am aware) is to drop and re-create the table using the ON option.
You might try:
Note that this example does not include any constraints, indexes, dependent objects or anything else. Actual mileage may vary. Wear your seatbelt.
CREATE MyTable_Temp (
Foo varchar(10) NOT NULL,
Bar int NULL
) ON [MyFileGroup]
INSERT INTO MyTable_Temp (Foo, Bar)
SELECT Foo, Bar
DROP TABLE MyTable
sp_rename N'MyTable', N'MyTableTemp'
It's true that those are the only ways to do it by script. However, if you only need to do it for a few tables, it may be quicker to use Enterprise Manager instead.