filegroupe

  • 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)

  • 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


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply