Move file help

  • I figured it out incase anyone wants to do the same:

    declare @FileName varchar(1000), @FilePath varchar(1000), @FullPath varchar(1000), @destPath varchar(1000), @destFileName varchar(1000),

    @destFullPath varchar(1000), @move varchar(1000)

    SET @FilePath = '\\164.43.10.23\global$\Price_List_Files\run_sql\'

    SET @FileName = Left(CONVERT(VARCHAR(10),GETDATE(),120),10) + '_All.txt'

    SET @FullPath = @FilePath + @FileName

    SET @destPath = '\\164.43.10.23\global$\Price_List_Files\completed_drop\_SQL-file-Archive\'

    SET @destFileName = replace(CONVERT(VARCHAR(8),GETDATE(),108),':','')

    Set @destFullPath = @destPath + substring(@FileName,1,len(@FileName) - 4) + '_imported_' + @destFileName + '.txt'

    set @move ='move ' + @FullPath + ' '+ @destFullPath

    exec master..xp_cmdshell @move

Viewing post 1 (of 2 total)

You must be logged in to reply to this topic. Login to reply