Link to home
Start Free TrialLog in
Avatar of ykchakri
ykchakri

asked on

Merging database files

Hi Experts,

Is it possible to merge 2 datafiles (test.mdf, test1.ndf)in to one. Due to in-sufficient disk space, I have created test1.ndf on another partition, so that the database 'test' could grow. Now that I am moving this database to another server, where I have plenty of disk space, I want to have all the data into one single .mdf file. How can I do that ?
Avatar of rgollakota
rgollakota

1.Create a new database (with no objects) on your new server with a single file.
2.Generate the SQL Scripts from the existing database.
3. Run these scripts on your new database
4. Use DTS or BCP to get the data from one server to the other server.
ASKER CERTIFIED SOLUTION
Avatar of Mogalappa Adaki
Mogalappa Adaki

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Rename your old database (exec sp_renamedb ...)
Create your new database
Use the enterprise manager, expand server, expand database, right click on your old database, choose all tasks, choose export data.
Select the old DB as your source and the new DB as your destination. You can transport objects and data from one database to another.
Avatar of ykchakri

ASKER

Hi Mogaruna,

That works good for the files in the same file group. Now, I have a file in another file group. Is there any way that I can merge this file with the PRIMARY file group. I am thinking of dropping the objects in that file group and re-create in the PRIMARY. But, there must be an easier way than that.