What's in a VBscript?

  • I have the following code generated by the wizard for a DTS import from an Access Database

    DTSDestination("INSTALLED") = DTSSource("INSTALLED")

    DTSDestination("SHIPPED") = DTSSource("SHIPPED")

    I want to modify the way that the "SHIPPED" date is imported, there seems to be some wierd errors in the access database that drop in a 1889 date into that field, sometimes I forget to clean that up, but all I do is make it the same date as the INSTALLED date.

    I was thinking that all I had to do was modify these lines to read

    IF DTSSource("SHIPPED") < '12/31/1900' THEN

    DTSDestination("SHIPPED") = DTSSource("INSTALLED")

    ELSE

    DTSDestination("SHIPPED") = DTSSource("SHIPPED")

    ENDIF

    is that right?

    -Francisco


    -Francisco

  • Looks ok. Need a space between end and if. Think you need to double quote the date literal too.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • DOH!

    Thanks...

    I added an additioanl clause for when the SHIPPED date is NULL, so it looks like this...

    IF IsNull(DTSSource("SHIPPED")) THEN

    DTSDestination("SHIPPED") = DTSSource("SHIPPED")

    ELSE

    IF DateValue(DTSSource("SHIPPED")) < DateValue("12/31/1900") THEN

    DTSDestination("SHIPPED") = DTSSource("INSTALLED")

    ELSE

    DTSDestination("SHIPPED") = DTSSource("SHIPPED")

    END IF

    END IF

    Thanks for the input!

    -Francisco


    -Francisco

  • Should work. In the null case you could just set the function to null since you already tested, save a property lookup. You could also consider handling the null or even the entire test in your sql statement, saving the custom transform.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

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

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