I need to update a process on a SQL 2005 package.
I need to copy, rename, and delete a file.
Here is my code:
@TodayDate as varchar(40),
@TodayHour as varchar(40),
@TodayMinu as varchar(40),
@NewFileName as varchar(100),
@cmdstr as varchar(328)
SELECT @TodayDate = CONVERT(varchar(10), GETDATE(), 112)
SELECT @TodayHour = DATEPART(hh,GETDATE())
SELECT @TodayMinu = DATEPART(mi,GETDATE())
SELECT @NewFileName = 'myfileone' + '_' + @TodayDate + '_' + @TodayHour + '_' + @TodayMinu + '.mdb'
set @cmdstr='copy \\servername\folderpath\myfileone.mdb \\servername\folderpath\' + @NewFileName
EXEC master..xp_cmdshell @cmdstr
exec master..xp_cmdshell 'del \\servername\folderpath\myfileone.mdb'
The stored procedure does run without errors but I get the below message:
Access is denied.
Why am I getting this message? The login I am running this under has full permissions, How do I resolve this error?