two mdf files back to one… | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

two mdf files back to one…

Hello! On SQL server i have a database which has two .mdf files and two log files. This was made because i didn’t have enough space on one disk, so i had to split it. Now i bought a new disk and i want to join those files back to one so i would have one .mdf and one log file. Can anyone tell me how i do that without risk of damaging the database. Thanx for all the help… lp janez
First run dbcc shrinkfile(<fileid>, emptyfile) followed by ALTER DATABASE dbname REMOVE FILE logicalfilename you can find out the logicalfilename or the fileid from running select * from sysfiles1 in the db concerned. I have used this for data files, I assume it should work for logs. Might need to set the db in SIMPLE recovery mode, and/or run BACKUP TRAN dbname WITH NO_LOG several times… Tom Pullen
DBA, Oxfam GB
I think SP_DETACH_DB to detach and SP_ATTACH_DB to attach the database wll do the process, on top of Tom’s process. Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
May be I missing something here.
Lord: Do you want to get one mdf and one log file, when you have 2 mdf (with cluster index, non cluster index, and different filegroup name) and 2 log? Or both mdf belong to same filegroup? Luis Martin
Moderator
SQL-Server-Performance.com All postings are provided “AS IS” with no warranties for accuracy.
LouisMartin: I have 2 mdf and 2 log files for the same database. At first there was only one mdf and one log, but then i had to split them becaus of diskspace problems…
I undertand that. The question is: both mdf belong to same filegroup (see BOL).
Luis Martin
Moderator
SQL-Server-Performance.com All postings are provided “AS IS” with no warranties for accuracy.
]]>