December 29, 2010 at 5:15 am
i have 20 tables in my database that start with "Crm...".
these tables created on default filegroupe and now i want to move these tables to another filegroupe.
these tables didnt have any relation and fk.
how to move these tables to another filegroupe????
this is my script but this script is used for only one table CrmAccounts.
Alter table CrmAccounts drop constraint pk_CrmConstraintId with (move to CrmFileGroupe)
December 29, 2010 at 8:24 am
This will generate the ALTER TABLE statements for you.
SELECT 'ALTER TABLE ' + QUOTENAME(ss.name) + '.' + QUOTENAME(st.name) +
' DROP CONSTRAINT ' + QUOTENAME(skc.name) +
' WITH (MOVE TO CrmFileGroupe)'
FROM sys.tables st
JOIN sys.key_constraints skc
ON st.object_id = skc.parent_object_id
JOIN sys.schemas ss
ON st.schema_id = ss.schema_id
WHERE st.name like 'Crm%';
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply