Professional Documents
Culture Documents
Buscar
I need to move and rename a file but for reasons I'm not going into can't use SSIS or DTS. I'm trying to use xp_cmdshell an
getting the message "The syntax of the command is incorrect". I'm using examples I've found on line and am confused as to
1 what I've done wrong. The rename should add the date onto the filename, for example EandWTest.txt should be moved to a
archive folder and renamed EandWTest_0110523_16_07.txt.
This is the code I've found and am trying to fit my needs, I'm not actually using the variables to stipulate the filename and pa
but will do that when I've got the basic code working:
DECLARE
@TodayDate as varchar(40),
@TodayHour as varchar(40),
@TodayMinu as varchar(40),
5. @NewFileName as varchar(100),
@cmdstr as varchar(128),
@cmd VARCHAR(255),
@sFileName AS VARCHAR(255),
@sPath AS VARCHAR(255)
10.
SET @sFileName = 'EandWTest.txt'
SET @sPath = 'C:\Auto Import\Auto Import\'
Many thanks.
Mrs_Fatherjack
5.2k ● 66 ● 69 ● 77
https://ask.sqlservercentral.com/questions/40365/moving-and-renaming-files-using-xp-cmdshell.html 1/3
27/1/2018 Moving and renaming files using xp_cmdshell - SQL Server Q&A from the SQL Server Central community
WilliamD
26.2k ● 18 ● 37 ● 48
23 May 2011 a
Mrs_Fath
You're welcome.
23 May 2011 a
Your answer
[Ocultar previsualización]
https://ask.sqlservercentral.com/questions/40365/moving-and-renaming-files-using-xp-cmdshell.html 2/3
27/1/2018 Moving and renaming files using xp_cmdshell - SQL Server Q&A from the SQL Server Central community
https://ask.sqlservercentral.com/questions/40365/moving-and-renaming-files-using-xp-cmdshell.html 3/3