Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Difference betweens BCP and BULK INSERT

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-12-18 : 14:00:02
Bob Osola writes "What are the gotchas between the two approaches? I have a BCP routine in an application which works fine. It looks like this: "bcp dbname.dbo.tblname in c:\..path\import.tsv -m 1000 -f c:\..path\format.txt -e C:\..path\err.txt -T"

I wanted to convert this to an sproc rather than having to call BCP as an external routine, so did this:
Create Procedure spBulkImport
AS
BULK INSERT dbname.dbo.tblname
FROM 'C:\..path\import.tsv'
WITH
(
FIELDTERMINATOR = '\t'
, FORMATFILE = 'c:\..path\format.txt'
, MAXERRORS = 1000
, ROWTERMINATOR = '\r\n'
)
But I get the follwing error: "Bulk data conversion error (truncation) for row 2 column 12 (OrgOrDup)"
The relevant part of the format file is this:
...stuff
11 SQLCHAR 0 30 "\t" 11 County
12 SQLCHAR 0 3 "\r\n" 12 OrgOrDup
13 SQLTINYINT 0 0 "" 0 PayCheckType
... stuff
OrgOrDup is a char length 3, and it works fine in BCP. Any ideas what I could be doing wrong? (I have tried dropping the Row and Field terminator args - no joy). Any pointers gratefully received..."
   

- Advertisement -