dbTalk Databases Forums  

Problem with DTS and Bad Dates

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Problem with DTS and Bad Dates in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
robboll
 
Posts: n/a

Default Problem with DTS and Bad Dates - 08-24-2006 , 10:37 AM






I have a DTS routine that I have been using to append dates into a SQL
Server 2000 table and it usually works great. It appends to a
Smalldatetime column -- It is as follows:

'************************************************* *********************
' Visual Basic Transformation Script
' Copy each source column to the
' destination column
'************************************************* ***********************

Function Main()
'DTSDestination("Col002") = DTSSource("Col002")
if DTSSource("Col002") = "99999999" or DTSSource("Col002") = Null then

Main = DTSTransforStat_SkipRow
else
DTSDestination("Col002") = mid(DTSSource("Col002"),1,4) & "/" &
mid(DTSSource("Col002"),5,2) & "/" & mid(DTSSource("Col002"),7,2)
End if
Main = DTSTransformStat_OK
End Function

The problem is when it hits a bad date such as: 19910631

Instead of ignoring the bad date the entire DTS job fails. Obviously
this is something that should be validated at data entry, but
unfortunately the only control I have is when appending to the table.
Any suggestions as to what I can add to the code to account for bad
date entries. Thank in advance.

RBollinger


Reply With Quote
  #2  
Old   
robboll
 
Posts: n/a

Default Re: Problem with DTS and Bad Dates - 08-24-2006 , 06:55 PM






found the solution:

Function Main()
Dim sYear, sMonth, sDay, sDate
sYear = Left( DTSSource("Col002"),4)
sMonth = right( DTSSource("Col002"),2)
sDay = mid(DTSSource("Col002"),5,2)
sDate = sYear & "-" & sMonth & "-" & sDay
If IsDate(sDate) Then
DTSDestination("Col002") = sDate
Else
DTSDestination("Col002") = Null
End If
Main = DTSTransformStat_OK
End Function



robboll wrote:
Quote:
I have a DTS routine that I have been using to append dates into a SQL
Server 2000 table and it usually works great. It appends to a
Smalldatetime column -- It is as follows:

'************************************************* *********************
' Visual Basic Transformation Script
' Copy each source column to the
' destination column
'************************************************* ***********************

Function Main()
'DTSDestination("Col002") = DTSSource("Col002")
if DTSSource("Col002") = "99999999" or DTSSource("Col002") = Null then

Main = DTSTransforStat_SkipRow
else
DTSDestination("Col002") = mid(DTSSource("Col002"),1,4) & "/" &
mid(DTSSource("Col002"),5,2) & "/" & mid(DTSSource("Col002"),7,2)
End if
Main = DTSTransformStat_OK
End Function

The problem is when it hits a bad date such as: 19910631

Instead of ignoring the bad date the entire DTS job fails. Obviously
this is something that should be validated at data entry, but
unfortunately the only control I have is when appending to the table.
Any suggestions as to what I can add to the code to account for bad
date entries. Thank in advance.

RBollinger


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.