Created
April 24, 2016 16:11
-
-
Save niisar/96cb7327c01640549350cf2f630d788c to your computer and use it in GitHub Desktop.
Delete FILESTREAM data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Delete row #1 | |
DELETE FROM PhotoAlbum WHERE PhotoId = 1 | |
SELECT * FROM PhotoAlbum | |
-- Forcing garbage collection won't delete the file without a BACKUP if using FULL recovery model | |
EXEC sp_filestream_force_garbage_collection | |
-- Switch from FULL to SIMPLE recovery model | |
SELECT name, recovery_model_desc FROM sys.databases WHERE name = 'PhotoLibrary' | |
ALTER DATABASE PhotoLibrary SET RECOVERY SIMPLE | |
SELECT name, recovery_model_desc FROM sys.databases WHERE name = 'PhotoLibrary' | |
-- Forcing garbage collection will now delete the file immediately | |
EXEC sp_filestream_force_garbage_collection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment