2012年3月20日星期二

bcp problem

I am trying to import data from a file. The file has entries like
1437"PJ_001"3"PJ/001 "
5746"PJ_002"3"PJ/002 "
while the table is defined as
kint4nulls
ftext16nulls
cint4nulls
pchar30nulls
When I use command
bcp "MyDatabase.dbo.MyTable" in "D:\Development\MyDatabase\MyFile.txt" -c
-S"MyPc\MyInstance" -U"sa" -P"MyPass"
I get error message
SQLState = 22001, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]String data, right truncation
on every entry. Can anybody explain why, or even better, how to get this
working?
Thanks in advance!
Hans.
Have you looked at using a format file for your BCP command? BOL will
explain how to use them.
"Hans" <Hans@.discussions.microsoft.com> wrote in message
news:F46030CF-34BD-45F9-BF49-9E8868A3207F@.microsoft.com...
> I am trying to import data from a file. The file has entries like
> 1437 "PJ_001" 3 "PJ/001 "
> 5746 "PJ_002" 3 "PJ/002 "
> while the table is defined as
> k int 4 nulls
> f text 16 nulls
> c int 4 nulls
> p char 30 nulls
> When I use command
> bcp "MyDatabase.dbo.MyTable" in "D:\Development\MyDatabase\MyFile.txt" -c
> -S"MyPc\MyInstance" -U"sa" -P"MyPass"
> I get error message
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][ODBC SQL Server Driver]String data, right truncation
> on every entry. Can anybody explain why, or even better, how to get this
> working?
> Thanks in advance!
> Hans.

没有评论:

发表评论