Hi!!!
I would like change table's filegroup.
How can I do by script?
Thank you.
Bye.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:
CREATE MyTable_Temp (
Foo varchar(10) NOT NULL,
Bar int NULL
) ON [MyFileGroup]
INSERT INTO MyTable_Temp (Foo, Bar)
SELECT Foo, Bar
FROM MyTable
DROP TABLE MyTable
sp_rename N'MyTable', N'MyTableTemp'
Note that this example does not include any constraints, indexes, dependent objects or anything else. Actual mileage may vary. Wear your seatbelt.
Regards,
Hugh Scott|||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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment