freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Carl Johnson <CJohnson AT Acadian-Asset.com>
- To: 'FreeTDS Development Group' <freetds AT lists.ibiblio.org>
- Subject: [freetds] bcp bug with null dates
- Date: Mon, 3 Mar 2003 12:22:56 -0500
If you use freebcp to copy data out of a datetime or smalldatetime field
with a null value, the output file contains "1900-01-01 00:00:00.000"
instead of nothing for this field.
The following code demonstrates the problem:
SQL to create table:
create table datebug (DateField datetime null)
insert datebug values (null)
Freebcp command to create file:
freebcp datebug out datebug.bcp -S<server> -U<user> -P<password> -c
This is my first post to the group, and I'm still getting familiar with the
sources, but it looks like the problem is in dblib/bcp.c:683
/* if we are converting datetime to string, need to override
any
* date time formats already established
*/
if ((bcpcol->db_type == SYBDATETIME || bcpcol->db_type ==
SYBDATETIME4)
&& (hostcol->datatype == SYBCHAR || hostcol->datatype ==
SYBVARCHAR)) {
==> memset(&when, 0, sizeof(when));
tds_datecrack(bcpcol->db_type, bcpcol->data, &when);
buflen = tds_strftime((char*)outbuf, buflen, "%Y-%m-%d
%H:%M:%S.%z", &when);
} else {
Shouldn't there be a check to see if bcpcol->data_size == 0 before the
datecrack?
I'm using freetds version 0.61 on Solaris 2.6 against a SQL Server 2000
database, although I get the same results connecting to Sybase 11.92.
Thanks a lot - freetds and sqsh are really helping us to migrate from Sybase
to SQL Server!
-
[freetds] bcp bug with null dates,
Carl Johnson, 03/03/2003
- <Possible follow-up(s)>
- RE: [freetds] bcp bug with null dates, Lowden, James K, 03/03/2003
Archive powered by MHonArc 2.6.24.