SQL - Emptying Secondary Data File We have two filegroup PRIMARY and SECONDARY. Objective is to merge SECONDARY partition with PRIMARY.
On running below command, following error is coming:
DBCC SHRINKFILE (N'ABC_Secondary', EMPTYFILE);  
GO 

DBCC SHRINKFILE: Heap page 3:54888929 could not be moved.
Msg 2555, Level 16, State 1, Line 7
Cannot move all contents of file &quot;ABC_Secondary&quot; to other places to complete the emptyfile operation.
The statement has been terminated.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Msg 1105, Level 17, State 2, Line 7
Could not allocate space for object 'dbo.Contact' in database 'ABC' because the 'SECONDARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.

Completion time: 2021-01-23T10:51:18.9766221-07:00
See below database usage:
DbName  FileName    type_desc   CurrentSizeMB   FreeSpaceMB
ABC     ABC             ROWS    1791360.000000  357524.062500
ABC     ABC_log         LOG      904.000000       858.640625
ABC     ABC_Secondary   ROWS    483274.000000   437450.437500
the 'SECONDARY' filegroup is full

Read Database Files and Filegroups.
To move all your data off of a File to other Files in the same Filegroup, use DBCC SHRINKFILE (N'SomeFile', EMPTYFILE);
To move your data off of a Filegroup to some other filegroup rebuild it targeting the new Filegroup, using ALTER TABLE REBUILD for a heap, or by droping the clustered index and recreating it on the new filegroup.