Do you need to combine or merge two data files (MDF or NDF)? There are a number of complicated options available or you can use the two lines of code below to do the trick… It’s up to you. This method works with both SQL Server 2005 and SQL Server 2008.
DBCC SHRINKFILE(LogicalNameOfFileToRemove, EMPTYFILE)
ALTER DATABASE DataBaseName REMOVE FILE LogicalNameOfFileToRemove
If you don’t know the logical name of your MS SQL Server files use the following T-SQL query:
name AS LogicalName
,sys.database_files.physical_name AS PhysicalName