I am in the process of migrating one of the databases that has multiple filegroups into Azure Sql Server. Azure does not seem to support multiple file groups yet according to DMA(Data Migration Assistant).
Now I would like to merge filegroups back into single file.
By searching on internet I found out the following commands to shrink the filegroup to empty the filegroup. Which I believe just merge the content into Primary filegroup and then the filegroup can be removed.
DBCC SHRINKFILE ('ndfFile', EMPTYFILE);
GO
ALTER DATABASE myDb REMOVE file ndfFile
GO
When I run this I get the following error message:
Msg 2556, Level 16, State 1, Line 2
There is insufficient space in the filegroup to complete the emptyfile operation.
I have checked the Primary file group file and auto growth is enabled
I have taken a full backup and removed the database and restored the database again but again no success.
I have also tried to create a new database with a single file and tried to use import/export to copy the data into new database. However import/export wizard does only create tables but not referential integrity constraint nor primary key etc.
When I create the objects by using Generate Scripts feature to create all objects then I cannot copy the data even the "Insert Identity" option is selected.
Question 1: Is there any way that I can restore MyDb.bak backup file into a single file (and log file)?
Question 2: Is there any way to merge filegroups into single file?
