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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to avoid Nulls

Status
Not open for further replies.

srajeevkumar

IS-IT--Management
Dec 29, 2003
36
GB
Hello,

I am trying to import from a flat file into a database table using DTS. Two fields in my table does not allow nulls and are of Varchar datatype and default values have been set as '' for these two filed types.

Now when I choose the source to be a text file having 12 columns delimited by a comma. The DTS automatically converts those colums with no data ( For eg:- ,,) into Null. And since the two fields dont allow nulls , it fails on DTS execution. How can I not allow the DTS to convert the Empty ( ,,) to Nulls before reading from the text file.
I am really stuck with this.

Please do helpp meee.
Rgds

Rajeev
 
You could write an ActiveX script instead of using a direct copy within the Transform Data Task. In VB it would be a simple if statement

'**********************************************************************
' Visual Basic Transformation Script
'************************************************************************

' Copy each source column to the destination column
Function Main()
If IsNull( DTSSource("Colxxx") ) Then
DTSDestination("TargetColumn")= "substitute for null"
Main = DTSTransformStat_OK
Else
DTSDestination("TargetColumn")= DTSSource("Colxxx")
Main = DTSTransformStat_OK
End If
End Function


Sometimes the grass is greener on the other side because there is more manure there - original.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top