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!

column not being read as Null, causing fail 1

Status
Not open for further replies.

skitty123

Technical User
May 4, 2004
56
US
I am trying to import data from a .csv file into SQL Server using DTS. the file contains data like this:
Name, Price
PROD1, 10.50
PROD2, 11.2
,0
,0
XYZ, 0

The table I am importing into has the "name" column set as not allowing null so the rows 3 and 4 are causing an error
I modified my transformation script to check for nulls but it still does not work, I get the error:
"Insert Error, Column 1('name', DBTYPE_STR) status 10, attempt to insert null data or data which violates integrity constrants."

What Am I doing wrong?
----------------------------------------------
Here is my code:
' Copy each source column to the destination column
Function Main()

If Not IsNull (DTSSource("Rate")) Then
DTSDestination("rate") = DTSSource("Rate")
End If

If Not IsNull (DTSSource("name"))Then
DTSDestination("name") = DTSSource("name")
End If

Main = DTSTransformStat_OK
End Function
 
Try this:

Code:
'  Copy each source column to the destination column
Function Main()

  If Not (IsNull (DTSSource("Rate")) And IsNull (DTSSource("name"))) Then 
    DTSDestination("rate") = DTSSource("Rate") 
    DTSDestination("name") = DTSSource("name") 
    Main = DTSTransformStat_OK
  Else
    Main = DTSTransformStat_SkipRow
  End If    

End Function
HTH,
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top