I am having a problem with this script that I have to rename a file with the date at the end of it. When I run the program it is deleting the file. Any ideas what I have wrong?
@TodayDate as varchar(40),
@TodayHour as varchar(40),
@TodayMinu as varchar(40),
@NewFileName as varchar(100),
@cmdstr as varchar(128)
SELECT @TodayDate = CONVERT(VARCHAR(8), GETDATE(),112)
SELECT @NewFileName = 'Write-Off_Reports' + @TodayDate + '.xls'
set @cmdstr= 'move /Y "D:\HighJump Reports\Write-Off Reports\Write-Off_Reports.xls" "D:\HighJump Reports\Write-Off Reports\ "'+ @NewFileName
print @cmdstr EXEC master..xp_cmdshell @cmdstr