We help IT Professionals succeed at work.

Migrate .ndf into .mdf

JackW9653
JackW9653 asked
on
Hello Experts,
Is there a way to migrate an .ndf file back into the .mdf. They are both in the same filegroup of course, and I rememeber reading somewhere this could be done. Any assistance is greatly appreciated even if its to tell me that it can't be done.
Thanks,

JackW
Comment
Watch Question


First of all make sure you backup the database. Next would running DBCC command and shrink that file. Then you would remove ndf entry. Below are the commands

DBCC SHRINKFILE (DATAFILE.NDF,EMPTYFILE)
ALTER DATABASE <databasename> REMOVE FILE 'DATAFILE.NDF'

DATAFILE.NDF= Logical Name

Search BOL for DBCC SHRINKFILE

Author

Commented:
Thanks Kuki for your reply,  after a closer examination of the database there are 3 filegroups. One is the Primary and the other 2 match the names of the .ndf files. I rewrote my restore script using With Recovery, Replace and specified the .ndf files using MOVE TO and that worked to get all the tables so i can view them.

Thanks again for your solution, that was the method I was trying to remember.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.