Problem Using CInt When Encountering Empty String

  • Hello,

    I have a transformation in which the column of data at the flat file source is nine characters long, and typically contains a string of six or seven zeros with a non-zero number in the last two or three characters. If none of the records in that column were an empty string, I think I could get away with this:

    DTSDestination("TTLCrd") = CInt(DTSSource("Col004"))

    The destination is a SQL Server 2000 table, and the column is of type Integer. What do I do when Col004 is an empty string? I've tried a couple of different IF statements, but they have not worked. Empty strings need to become zero values.

    Thank you for your help.

    CSDunn

  • How about this:

    If IsNumeric(DTSSource("Col004")) Then

        DTSDestination("TTLCrd") = CInt(DTSSource("Col004"))

    Else

        DTSDestination("TTLCrd") = 0

    End If

  • Thank you for your response. I'll try this on Monday.

    cdun2

  • I applied the following, and I get a vbscript syntax error;

    DTSDestination("TTLCrd") = If IsNumeric(DTSSource("Col004")) Then DTSDestination("TTLCrd") = CInt(DTSSource("Col004")) Else DTSDestination("TTLCrd") = 0 End If

  • Sorry, I left 'DTSDestination("TTLCrd") = ' before the IF test. Let me get the proposed solution worked into the other transformations, and I'll check back.

    Thanks again!

    CSDunn

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply