moving data between files

  • We ran out of space on a drive a few days ago and had to create a new data file on another drive to keep the system up.

    We have since had the drive expanded so we have loads of free space. I want to delete the new data file, but before doing that i need to move all of its data to the other datafile. I cannot find any way to do this. Ive done a few google searches but my searches have turned up nothing. Can anyone advise how i go about doing this?

    Note, the temporarily created file is in a seperated file group from the MDF.

    Thanks all

  • You use DBCC SHRINKFILE with the EMPTYFILE option. Once the file is empty, it can be removed.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • If it's in a separate filegroup, how did it help with space? Tables have to be explicitly created onto new filegroups, they won't just use that space.

    If you explicitly moved tables onto that filegroup, you can move them back to primary in the same way, by moving the clustered index.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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