Tuesday, February 12, 2013 7:14 AM
We have a database with One .mdf file ,8 .ndf files and one lof file.
Now we want to create a database with only .mdf and .ldf from that existing db without secondary files.
could you please suggest me the options
Tuesday, February 12, 2013 7:30 AMFirst empty the files using the command
DBCC SHRINKFILE(<<LogicalFileName>> ,EMPTYFILE )Then drop the ndf files
--This would take a time depending on the size of your database.
--and data on the secondary file
Tuesday, February 12, 2013 9:09 AM
You can not do it that way. All data files are required when attaching a database only log file can be re-created.
You need to attach database using all files. After that you can drop the additional .ndf files from database as Sateesh suggested.
To remove a file you can use below command:
ALTER DATABASE [DatabaseName] REMOVE FILE [FileName]