I am trying to delete files in a folder except the last created file in the folder.
can you please help me with the logic.
The files in the folder are sql server audit files with the extension .sqlaudit
I cannot choose the files based on date because if the auditing data is not present on todays date . the old files can be deleted.
I am looking for a logic which should look at the files in the folder and delete all the files in that folder except the last created file in that folder.
I am using SQL Server 2008 R2 Enterprise edition RTM 64 bit on windows server 2008 R2 Enterprise edition sp1 64 bit