freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
[freetds] Freebcp copy into ms sql server fails if field is null
- From: "Thomas A. Lowery" <tlowery AT rparts.us>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: [freetds] Freebcp copy into ms sql server fails if field is null
- Date: Tue, 16 Nov 2004 15:27:38 -0500
My attempts to use freebcp to populate a database table results in
# Msg 20073, Level 2
# Attempt to bulk-copy a NULL value into Server column which does not accept
NULL values.
There appears to be problem if any of the columns are null.
Here's a script to demo the problem.
#!/bin/bash
USER=myuser
PASS=mypass
SERVER=server
do_sqsh()
{
sqsh -e -b -U $USER -P $PASS -D db -S $SERVER -C "$*";
}
do_sqsh 'drop table dbo.test_me'
do_sqsh 'create table dbo.test_me (i integer not null primary key, c
varchar(10) null)'
do_sqsh "insert into dbo.test_me values (3,'string')"
do_sqsh "insert into dbo.test_me values (1,'string2')"
do_sqsh 'insert into dbo.test_me values (2,null)'
do_sqsh 'select * from dbo.test_me'
freebcp db.dbo.test_me out test_me.txt -S $SERVER -U $USER -P $PASS -c
do_sqsh 'truncate table dbo.test_me'
freebcp db.dbo.test_me in test_me.txt -S $SERVER -U $USER -P $PASS -c
exit;
# freebcp -v
# freebcp version $Id: freebcp.c,v 1.17 2003/01/26 10:27:35 freddy77 Exp $
# [3] server.db.1> drop table dbo.test_me
# [3] server.db.1> create table dbo.test_me (i integer not null primary key,
c varchar(10) null)
# [3] server.db.1> insert into dbo.test_me values (3,'string')
# [3] server.db.1> insert into dbo.test_me values (1,'string2')
# [3] server.db.1> insert into dbo.test_me values (2,null)
# [3] server.db.1> select * from dbo.test_me
# i c
# ----------- ----------
# 1 string2
# 2 NULL
# 3 string
#
# (3 rows affected)
#
# Starting copy...
#
# firstrow = 0 row_of_query = 3 rows written 3
# 3 rows copied.
# [3] server.db.1> truncate table dbo.test_me
#
# Starting copy...
#
# Msg 20073, Level 2
# Attempt to bulk-copy a NULL value into Server column which does not accept
NULL values.
#
# bcp copy in failed
-
[freetds] Freebcp copy into ms sql server fails if field is null,
Thomas A. Lowery, 11/16/2004
- <Possible follow-up(s)>
- RE: [freetds] Freebcp copy into ms sql server fails if field is null, Lowden, James K, 11/17/2004
Archive powered by MHonArc 2.6.24.