Tuesday, March 20, 2012

Rename a file

Hello,

I have a DTS process to import data from txt file to the sql.
The File name I import is LLEEOD.txt

and the directory is from a d:\ftp\newdata\

When my import process completes, I have to rename that file to the current date, lets say 01-11-2006.txt

I was trying to create another DTC (txt to txt) , but I have to provide a name myself. which is a problem, since this is a weekly process.

Is there are other ways to rename the txt file>

Thank you very much.I have not enough experience doing these kind of things.. but that should be possible using an activex script in DTS.|||thank you, but I do not have exp. in activex.|||I found a half way to my solution,
CAN ANYONE HELP ME OUT WITH REST OF IT?

CREATE PROCEDURE [dbo].[Table_Rename] AS

Declare @.NewName varchar(100)

Set @.NewName = cast(datepart(mm,getdate())as varchar(2))
+ '-' +cast(datepart(dd,getdate())as varchar(2))
+ '-' +cast(datepart(yyyy,getdate())as varchar(4)) +'ord'

Select @.NewName
print @.NewName

EXEC sp_rename 'Test_1', @.NewName
GO

Thank you.

No comments:

Post a Comment