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!

Skip Row in CSV import in a DTS

Status
Not open for further replies.

NeelyJ

IS-IT--Management
Dec 4, 2000
7
US
I am importing a csv into SQL2000. Below is a small sample of the file...

436,"KID'S TRKY "," ",0,1,199
445,"KID'S "," "," ",0,5,299,
445,"KID'S "," "," ",0,5,299,
"PRICE CHANGE RECS"
129,"BREAD #3",4,4," "," "," "
133,"DESSERT #2",5,5," "," "," "

The problem is I need to ignore the line "Price Change Recs". I have started an activex script but it imports a null value instead of ignoring the line completely. Anyone have any ideas? Here is the script.

If left(DTSSource(&quot;Col001&quot;), 1) <> &quot;P&quot; then
If DTSSource(&quot;Col005&quot;) = &quot;MODIFY&quot; THEN
DTSDestination(&quot;ITEM_NUMBER&quot;) = DTSSource(&quot;Col001&quot;) & &quot;-2&quot;
ELSE
DTSDestination(&quot;ITEM_NUMBER&quot;) = DTSSource(&quot;Col001&quot;) & &quot;-1&quot;
End If ' end add -1 or -2 if
Else
' *********Here is where I need the help
End If ' end if price change recs


Thanks for any help.
 
Hi,

You could try using the SkipInsert result.

This is a basic example

--start code
dim x
if DTSSource(&quot;col001&quot;) = &quot;PRICE CHANGE RECS&quot; then
x = DTSTransformation_SkipInsert
else
DTSDestination(&quot;ITEM_NUMBER&quot;) = DTSSource(&quot;col001&quot;)
x = DTSTransformation_OK
end if

Main = x


--end code

The results for x are basically the same as the default (I cannot check now, as I haven't got access to a SQL machine), but the OK one is what is entered by default when starting an activex, and the other one just replaces the &quot;OK&quot; with &quot;SkipInsert&quot;

This can be used with your situation as

--start code
dim x
if DTSSource(&quot;col001&quot;) = &quot;PRICE CHANGE RECS&quot; then
x = DTSTransformation_SkipInsert
else
If DTSSource(&quot;Col005&quot;) = &quot;MODIFY&quot; THEN
DTSDestination(&quot;ITEM_NUMBER&quot;) = DTSSource(&quot;Col001&quot;) & &quot;-2&quot;
ELSE
DTSDestination(&quot;ITEM_NUMBER&quot;) = DTSSource(&quot;Col001&quot;) & &quot;-1&quot;
End If
x = DTSTransformation_OK
end if

--end code
Hope it helps

Kevin

**************************************************************
Rock is Dead (Long Live Paper and Scissors)**************************************************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top