how to move table from .mdf to .ndf

  • I have table of 150GB. I need to move it from E:\SQL\database.MDF location to k:\SQL\database.NDF.

    can help me. Thanks in advance.

  • You have to assign the new file to a different logical filegroup in the database, otherwise you can't control it.

    Once you have done that, you rebuild the clustered index in the new filegroup. You'll be making the table unavailable during this process.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Can explain it a bit clear.. I am not get how to do it.

    step by step process please.

  • If there is any script belonging to it. please post it.

    Thanks in advance.

  • Which part do you need a script for?

    Do you have multiple files and filegroups already created for your database?

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Hello,

    First create the new filegroup

    USE master

    GO

    ALTER DATABASE Test1

    ADD FILEGROUP Test1FG1

    GO

    ALTER DATABASE Test1

    ADD FILE

    ( NAME = test1dat3,

    FILENAME = 'k:\SQL\database.NDF',

    SIZE = 200GB,

    FILEGROWTH = 10GB)

    TO FILEGROUP Test1FG1

    Then rebuild the clustered index into the new filegroup created

    CREATE CLUSTERED INDEX CIX_YourTable

    ON dbo.YourTable(YourClusteringKeyFields)

    WITH DROP_EXISTING

    ON [Test1FG1]

    And that's it. I hope this can clear things up.

  • Thanks

  • Hi All,

    how we can find one table is located in mdf file or ndf file ...

    Thanks in advance.

  • Hi - Start a new thread to post your questions!

Viewing 9 posts - 1 through 8 (of 8 total)

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