question

smithsp17 avatar image
smithsp17 asked

Managing Snapshot files

Hi, I'm using snapshot replication in SQL Server 2005. The snapshots are being created daily and put in a snapshot folder that I specified. How do I have those snapshot folders and their files deleted on a regular basis, (daily for example)? Under General-Subscription Expiration, I've tried changing the interval from the default to 24 hours, or 12 hours, but it doesn't seem to make a difference. Is there a job that runs that removes those snapshot directories that I can get to run more often? Thanks, Steve
database-snapshot
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

TimothyAWiseman avatar image
TimothyAWiseman answered
I do not believe there is any tool inside of replication that will clean those up for you. However, it is not hard to use other methods. My recommended approach would be to step outside of SQL Server and create a script either in python or PowerShell and then put that script on a schedule with the operating system. You could also write a script to do it in T-SQL and put that on the SQL Server Agent Scheduler, but that requires things like using XP_cmdshell that I recommend avoiding when possible.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

smithsp17 avatar image
smithsp17 answered
Thank you Timothy!
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.