I am trying to move and rename all the files with extension csv in the folder.
c:\folder\a.csv c:\Newfolder\a20141151011.csv datetime append after moving
c:\folder\b.csv c:\Newfolder\b20141151011.csv
I cannot use ssis it has to be done in TSQL
DECLARE @FILELOCATION VARCHAR(250)
DECLARE @FINALLOCATION VARCHAR(250)
DECLARE @FILENAME VARCHAR (250) = '*.CSV'
DECLARE @DESTINATIONFILENAME VARCHAR (250) --= @filename + '.txt'
SET @FILELOCATION = 'C:\folder\'
SET @FINALLOCATION = 'C:\Newfolder\'
DECLARE @C VARCHAR (2000)
SET @C = 'MOVE ' + @FILELOCATION + @FILENAME +' ' + @FINALLOCATION + @DESTINATIONFILENAME
exec master.dbo.xp_cmdshell@C