Showing posts with label import. Show all posts
Showing posts with label import. Show all posts

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.

Removing the negative sign from an integer

How can I remove the - after an import into a database. I want to be able to convert all negative numbers to positive, once the data has been imported into the table

Any ideas?

If you dont have too many rows (not in millions) you can run a quick UPDATE statement.

UPDATE yourTable SET colA = colA * -1 WHERE colA < 0

|||

forgot to say thanks, did the trick.

Wednesday, March 7, 2012

Removing formatting from imported file

I have a file I'm pulling from another type of database into an Excel spreadsheet and then using my dtsx package to import the spreadsheet into my SQL database. The problem I'm having is that one of the fields coming out of the database to the spreadsheet has the thousands seperator in the field that I want to use as a numeric field without the ",". Right now I have a macro that I run on the spreadsheet to reset the field to straight numbers without commas before importing it, but would like to configure my Integration package to do it automatically.

Any ideas would be appreciated.

Thanks in Advance

Bring the column in as a string, then use a Derived Column transform to clean it and cast it to a number.

Code Snippet

(DT_I4) (REPLACE( [YourColumn] ,",","" ) )