SQL Rename script

Last Post 27 May 2009 10:29 AM by JASBRYDEN. 1 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
JASBRYDEN
New Member
New Member

--
26 May 2009 05:37 AM
Hi the code I have below is what I am using to rename a text file that I have.

This is working great once it is in the location
"D:\Microsoft SQL Server\SQLExport\KCC\"

I want it to now move to
"D:\Microsoft SQLServer\SQLExport\KCC\KCCExtract\ "

but the out put I am getting is 'IN2'

while in the last location I got the correct output of 'IN20090526.txt'

Any idea of what I am doing incorrect ????


DECLARE
@TodayDate as varchar(40),
@TodayHour as varchar(40),
@TodayMinu as varchar(40),
@NewFileName as varchar(100),
@cmdstr as varchar(128)
SELECT @TodayDate = CONVERT(VARCHAR(8), GETDATE(),112)
SELECT @NewFileName = 'IN' + @TodayDate + '.txt'
print @NewFileName
set @cmdstr= 'MOVE /Y "D:\Microsoft SQL Server\SQLExport\KCC\KCCExtract\inventory.txt"
"D:\Microsoft SQLServer\SQLExport\KCC\KCCExtract\ "'
+ @NewFileName
print @cmdstr
EXEC master..xp_cmdshell @cmdstr
JASBRYDEN
New Member
New Member

--
27 May 2009 10:29 AM
No it did not work.

Now I am not seeing the text file, it looks like it got deleted.



Acceptable Use Policy
---