Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Combining two files into one

Author  Topic 

dbwilson4
Yak Posting Veteran

50 Posts

Posted - 2007-08-02 : 11:53:47
My database has two data files (sql 2005)...how do I combine them into one data file?

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-08-02 : 22:46:43
If they are in same file group, you can use 'dbcc shrinkfile' with emptyfile option to merge data. Then remove empty file with 'alter database ... remove file ...'.
Go to Top of Page

dbwilson4
Yak Posting Veteran

50 Posts

Posted - 2007-08-04 : 13:44:56
There are in the same filegroup.

Can you help me with the DBCC shrinkfile?

Here's the information: (this is the filegroup)
db1test 224mb
secondarydbtest 222mb
db1test_log 1mb


I want to merge db1test with secondarydbtest and get rid of secondarydbtest
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-08-04 : 20:16:51
dbcc shrinkfile ('file_name', emptyfile), you can find details in books online.
Go to Top of Page

bhuvnesh.dogra
Starting Member

22 Posts

Posted - 2010-02-05 : 07:42:27
We have a SQL 2000 server over here on which we have a large database of 200 GB having 2 datafiles , both in Primarry file group. Datafiles are IT1 (located oin E: drive) nd IT2(located on F: drive). IT1 size is 110 GB & IT2 is newly created data file with 89GB size.

Now we are trying to move all the data from IT1 to IT2 using

DBCC Shrinkfile('IT1',EMPTYFILE) command.


It's completed successfully just in milli secs. that is not the expected time to finish bcoz IT1 is so large . After completition, both files are still of same size means no data movement from IT1 to IT2. What can be reason that command completed prematurely?

For IT2, we have unrestricted growth by 64MB.. please get back to me ASAP
Go to Top of Page
   

- Advertisement -