Hi Team
I need to create a dtsx package to delete files older than 4 weeks on ROSSQL in folder D:\SQL BackUps. Can you guys perhaps send me some steps via screen shot, so can follow, thank you./forums/uploadfile/adba63/07302024114135AM/Delete back up file from NAS.dtsx

Jithu ThomasRank #437 · 5.7K reputationPosted Jul 30, 2024, 8:37 AM EDT
Open SQL Server Data Tools (SSDT):
Create a New SSIS Package:
Add a Foreach Loop Container:
D:\SQL BackUpsand the "Files" to*.*to loop through all files.User::FileName).Add a Script Task:
User::FileNameas a ReadOnlyVariable.using System; using System.IO; using Microsoft.SqlServer.Dts.Runtime; public void Main() { string fileName = Dts.Variables["User::FileName"].Value.ToString(); FileInfo fileInfo = new FileInfo(fileName); if (fileInfo.LastWriteTime < DateTime.Now.AddDays(-28)) { fileInfo.Delete(); Dts.TaskResult = (int)ScriptResults.Success; } else { Dts.TaskResult = (int)ScriptResults.Failure; } }