How to Safely Remove a SQL Server Data File Without Downtime


Introduction

Removing SQL Server Data File Without Downtime is one of important activities in enterprise production scenarios.  Managing storage efficiently in SQL Server is crucial, especially when dealing with multiple data files (.ndf) on different disks. Sometimes, an organization may need to decommission a disk or reclaim space by removing an extra .ndf file. However, simply deleting the file is not possible while it contains data.

Therefore, this article focuses on mimicking a real-world SQL Server setup where we move data from one .ndf file to another and use DBCC SHRINKFILE (EMPTYFILE) to ensure smooth data transfer without downtime. This method is preferred as it allows safe data redistribution while