Migrate .ndf into .mdf

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
JackW9653Asked:
Who is Participating?
 
binarykukiConnect With a Mentor Commented:

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

0
 
binarykukiCommented:
Search BOL for DBCC SHRINKFILE
0
 
JackW9653Author 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.
0
All Courses

From novice to tech pro — start learning today.