January 17, 2012 at 3:43 pm
You're welcome
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 18, 2012 at 7:41 am
Hi Geoff..
Like to know one thing regrading to your script
exec master.sys.xp_cmdshell 'PushD "\\YOUR\UNC\PATH" &&("forfiles.exe" /S /M "*.trn" /d -7 /c "cmd /c del @file") & PopD'
GO
to
exec master.sys.xp_cmdshell 'PushD "\\YOUR\UNC\PATH" &&("forfiles.exe" /S /M "*.trn" /d -7 /c "cmd /c echo @file") & PopD'
GO
When i run 1st script with del option it deletes the files but when i run with echo option it is not deleting files. so like to know whats echo does in script if you or anyone know.
January 18, 2012 at 7:53 am
if you rememeber, i gave the 2nd option with the 'echo' statement so you could see what files would be deleted.
i thought it might help you if you could see the files with an 'echo' command first so you knew exacly what would get 'del' later.
you only need the first statement with the 'del' command once you are comfortable with it,
January 18, 2012 at 8:03 am
okay got you GEOFF ..thanks thanks...
have a good day ahead if you are in USA..lol;)
January 18, 2012 at 8:04 am
i am and you're welcome.
January 18, 2012 at 9:00 am
Have you tried using xp_delete_file? Nothing wrong with the method Geoff suggested, personally I'd rather not enable xp_cmdshell unless it's absolutely necessary.
EXECUTE master.dbo.xp_delete_file
0-- 0 = backup file, 1 = report file
,@path-- base folder, i.e. '\\myserver\mybackupdir'
,@fileext-- file extension, i.e. 'trn'
,@deldate-- delete files older than this date
,1-- 1 = include first-level subfolders, 0 = don't include subfolders
Viewing 6 posts - 16 through 20 (of 20 total)
You must be logged in to reply to this topic. Login to reply