Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invalid entries in text file 1

Status
Not open for further replies.

sedgely

Technical User
Feb 21, 2002
406
GB
i have a DTS job set up to import the contents of a text file into a SQL table. the problem i have is that some of the fields are time fields and the application that creates the text file puts in a colon :)) where the field is blank. i am looking at the possiblity of changing the application but at the moment, that is a no goer.
is there a way to build something into the DTS job to say &quot;if this field contains &quot;:&quot; then make the field <null>&quot;
i am new to DTS, and could do with some good advice.
Thanks in advance

Cheers, Craig
Si fractum non sit, noli id reficere
 
You will need to use an ActiveX transformation. I assume that you have a Transform Data task that pumps data from the text file into the database. Right-click on the transform line between the source and destination connections. Go to the Transformations tab and locate the mapping for the columns in question.

Click on the mapping line and delete it, then drag and drop the source column name onto the destination column name. Select ActiveX Script from the Create New Transformation dialog box and click OK. Choose Properties... Modify the script below to fit your needs. I am not a VB scripting expert, but this should be close. Good luck!


Code:
'**********************************************************************
'  Visual Basic Transformation Script
'************************************************************************

'  Copy each source column to the destination column
Function Main()
	IF DTSSource(&quot;ColumnName&quot;) = &quot;:&quot; THEN DTSDestination(&quot;ColumnName&quot;) = Null  ELSE DTSDestination(&quot;ColumnName&quot;) = DTSSource(&quot;ColumnName&quot;)

	Main = DTSTransformStat_OK
End Function

--Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
Thanks Angel
Will try this and let you know


Cheers, Craig
Si fractum non sit, noli id reficere
 
Angel
Have now tried your solution and with a bit of &quot;tinkering&quot; have got what i needed. Many thanks Have a star

Cheers, Craig
Si fractum non sit, noli id reficere
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top