Re: bcp problem
From: Darren Green (darren.green_at_reply-to-newsgroup-sqldts.com)
Date: 12/14/04
- Next message: Stephen Russell: "Re: DST with Excel and NULLS instead of Numbers"
- Previous message: Hans: "bcp problem"
- In reply to: Hans: "bcp problem"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 14 Dec 2004 15:59:41 -0000
Your data will not fit into the columns. Take your last column, it is 32
chars wide, because bcp has no concept of text qualifiers, so they are part
of the data. I assume it is tab delimited except they did not come out very
well in a newsgroup post.
You could try using a format file, where the column delimiters would be
tab + "
" + tab
tab + "
and the row delimiter is " + cr + lf.
By hand coding the column and row delimiters you can make the extra text
qualifiers be part of the delimiter and thus get stripped out.
Or
Just use DTS as it supports text qualifiers.
If you want to stick with bcp, then just try using the Bulk Insert Task, as
this has a nice format file generation option built it. The format file can
then be used with bcp instead.
-- Darren Green http://www.sqldts.com "Hans" <Hans@discussions.microsoft.com> wrote in message news:F07776E3-8795-4A4D-930A-B42C28A9FC3C@microsoft.com... > I posted this in Rools too, but the response rate is rather low, so here's my > question: > > 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.
- Next message: Stephen Russell: "Re: DST with Excel and NULLS instead of Numbers"
- Previous message: Hans: "bcp problem"
- In reply to: Hans: "bcp problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|