0

I am working in sql server 2016 with Filestream attribute column. I have a column with filestream attribute activated on it. when I insert a reacord in TSQL , the associated file is created in Filestream container folder which is correct. but the problem is that when I delete a row , the assoicated file in filestream container remains and won't be deleted. as far as I know this shouldn't happen and the file is completely related to its record, so why doesn't it delete?

Thank you

1 Answer 1

2

Unneeded filestream container files are physically deleted by a separate background garbage collection process. The files will eventually be deleted to reclaim the storage, just not in real time.

You can force garbage collection to occur immediately using sp_filestream_force_garbage_collection.

2
  • ... and, if I remember correctly, we also need to cycle the transaction log (either a transaction log backup or if in simple recovery a checkpoint occurs). Oct 14, 2018 at 10:59
  • @TiborKaraszi, yep, that's called out in the GC doc link I referenced.
    – Dan Guzman
    Oct 14, 2018 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.