all groups > sql server dts > july 2007 >
You're in the

sql server dts

group:

Copying datetime fields from FoxPro 6 tables to SQL Server 2000 (D


Copying datetime fields from FoxPro 6 tables to SQL Server 2000 (D B. Chernick
7/3/2007 9:20:00 AM
sql server dts: I am trying to create a dts package to copy a FoxPro 6 table to SQL 2000. I
seem to be having problems with the datetime fields. The usual error is
something like this: Insert Error, column 22('<column name>,
DBTYPE_DBTIMESTAMP), status 6: Data overflow. Invalid character value for
cast specification.

There do appear to be a number of null date records in the source table and
what I have been trying to do is write a script to allow for this. I have
made all datetime fields in the destination table nullable and I have tried
to modify the transformation script for the date fields as follows:

if isnull(DTSSource("bdte").value) then
DTSDestination("bdte") = null
Else
DTSDestination("bdte") = DTSSource("bdte")
End if

Any suggestions? (Admittedly I have not worked all that much with DTS or
Re: Copying datetime fields from FoxPro 6 tables to SQL Server 2000 (D Cindy Winegarden
7/3/2007 9:24:14 PM
[quoted text, click to view]


Hi B.,

FoxPro Date and DateTime fields can have three types of values, a legitimate
Date/DateTime value, Null in newer tables that allow Null values, and
"Empty." Empty is not the same as Null.

Are you perhaps running into Empty dates rather than Null dates?

--
Cindy Winegarden
cindy@cindywinegarden.com

VFP OLE DB: http://msdn2.microsoft.com/en-us/vfoxpro/bb190232.aspx
VFP ODBC: http://msdn2.microsoft.com/en-us/vfoxpro/bb190233.aspx
Re: Copying datetime fields from FoxPro 6 tables to SQL Server 2000 (D Allan Mitchell
7/4/2007 12:00:00 AM
Hello B. Chernick,

Are you sure that is the problem? It could well be

1. The values from the Foxpro side are simply not convertible to the SQL
Server version even if they look right in Foxpro
2. You have junk data in the Foxpro column

Here is where we do a conversion to handle dates in DTS from char data

http://www.sqldts.com/249.aspx

--

Allan Mitchell
http://wiki.sqlis.com | http://www.sqlis.com | http://www.sqldts.com |
http://www.konesans.com

[quoted text, click to view]

Re: Copying datetime fields from FoxPro 6 tables to SQL Server 200 B. Chernick
7/4/2007 2:42:01 AM
Actually as it turns out, the problem wasn't the null fields, it was bad data
in a datetime field. (year 0980 in one case. ???) Since I was out of time
and patience, and since I have little experience with either FoxPro or
VBScript, I decided to go with the brute force approach and wrote a little
VB.Net program that simply put every read of a date field inside a try-catch
block. If it crashes, stick a null date in SQL Server. Problem solved.

[quoted text, click to view]
Re: Copying datetime fields from FoxPro 6 tables to SQL Server 200 B. Chernick
7/6/2007 11:52:00 AM
I'm not sure. (Actually I am not that familiar with FoxPro6 or it's
terminology). However there does seem to be a problem with bad data, as near
as I can tell. At least one of the date fields displays a year of 0980 when
viewed within the FoxPro6 browser/IDE.

[quoted text, click to view]
Re: Copying datetime fields from FoxPro 6 tables to SQL Server 200 Cindy Winegarden
7/9/2007 6:55:46 PM
[quoted text, click to view]


Hi!

The VFP valid date range is {^0001/01/01} to {^9999/12/31}. Although I got
an error message in VFP for {^0001/01/01} with SET DATE SHORT and SET DATE
LONG, when I used SET DATE AMERICAN it accepted {^0001/01/01} as a valid
date.

When trying to import data to SQL Server I got errors importing my test
dates to a DateTime and ShortDateTime I was able to import the values
correctly as VarChar values. Note that FoxPro stores dates internally in
character format.

--
Cindy Winegarden
cindy@cindywinegarden.com

VFP OLE DB: http://msdn2.microsoft.com/en-us/vfoxpro/bb190232.aspx
VFP ODBC: http://msdn2.microsoft.com/en-us/vfoxpro/bb190233.aspx
Re: Copying datetime fields from FoxPro 6 tables to SQL Server 200 B. Chernick
7/10/2007 8:18:03 AM
I'm sorry but I have no idea what you are referring to. Are you talking
about editing the DTS package? If so, which editing screens?

[quoted text, click to view]
Re: Copying datetime fields from FoxPro 6 tables to SQL Server 200 Russell Fields
7/10/2007 11:17:16 AM
Also, SQL Server's valid date range is 1753/01/01 through 9999/12/31.

RLF
[quoted text, click to view]

Re: Copying datetime fields from FoxPro 6 tables to SQL Server 2000 (D C E Orr
7/19/2007 3:21:28 PM

Testing SQL Server 2000 version 8.00.2039 (SP4) I discovered that DTS
ActiveX VBscript of

adate = CDate(DTSSource("bdte"))
If adate = CDate("1899-12-30") Then adate = null
If adate < CDate("1753-01-01") Then adate = CDate("1753-01-01")
If adate > CDate("2079-06-06") Then adate = CDate("2079-06-06")
DTSDestination("bdte") = adate

seems to handle the FoxPro to SQL Server date conversions. The maximum
date of June 6, 2079 is the max for smalldatetime values (minimum is
1900-01-01). Apparently this is a result of using OBDC to connect to
FoxPro. FoxPro and SQL Server both accept dates up to 9999-12-31 for
datetime values. CDATE of the FoxPro null date value yields "1899-12-30
00:00:00:000"

In SQL Server 2005 SSIS Derived Column Transforms I was able to use
expressions such as "bdte > (DT_DATE)"9999-12-31" ?
(DT_DATE)"9999-12-31" : bdte"

Re: Copying datetime fields from FoxPro 6 tables to SQL Server 2000 (D tay sy
7/19/2007 9:54:26 PM
I have tried the script provided. However, there is scenario that it
works on date_adm and date_dschrg column but not my birthdate column.
All the three fields are date type and some of the records from within
consist of null date value.

I do not understand why the script do works on the date_adm and
date_dschrg but not on birthdate. I notice that some of the records of
null birthdate can go thru the script but it stop at one null birthdate
at roughly 15000th records.

I received error:
Errors encountered so far in this task: 1. ActiveX Scripting Transform
'AxScriptXform' encountered an invalid data value for 'birthdate' source
column.



AddThis Social Bookmark Button