this works for me, assuming the files and the folder structure exists: I'm moving a local file to a server named DAISY. The server has a share named C_DRIVE, and i have access to it.
@TodayDate as varchar(40),
@TodayHour as varchar(40),
@TodayMinu as varchar(40),
@NewFileName as varchar(100),
@cmdstr as varchar(128)
SELECT @TodayDate = CONVERT(varchar(10), GETDATE(), 112)
SELECT @TodayHour = DATEPART(hh,GETDATE())
SELECT @TodayMinu = DATEPART(mi,GETDATE())
SELECT @NewFileName = 'ImportData' + '_' + @TodayDate + '-' + Right('0' + @TodayHour,2) + Right('0' + @TodayMinu,2) + CASE WHEN DATEPART(hh,GETDATE()) >11 Then 'PM' ELSE 'AM' END + '.txt'
set @cmdstr='MOVE /Y C:\ImportData\ImportData.txt C:\ImportData\Finished\' + @NewFileName
set @cmdstr='MOVE /Y C:\ImportData\ImportData.txt \\DAISY\C_DRIVE\ImportData\Finished\' + @NewFileName
EXEC master..xp_cmdshell @cmdstr
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!