Deleting FILESTREAM Data

When a row is deleted from a FILESTREAM-enabled table, the row is removed from the table and the files associated with the row’s varbinary(max) FILESTREAM columns are removed from the file system. The files are deleted by the FILESTREAM garbage collector running on a separate background thread, so you might notice that the physical file is not removed from the FILESTREAM data container immediately.

SQL Server triggers the FILESTREAM garbage collector thread when a CHECKPOINT occurs, which, for databases that are not highly transactional, might take a long time to occur. If you want to trigger the garbage collector thread yourself, you can issue an explicit CHECKPOINT statement to the server.

Get Programming Microsoft® SQL Server® 2012 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.