Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Other SQL Server Topics / December 2006

Tip: Looking for answers? Try searching our database.

Bulk Insert Questions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jennifer - 29 Dec 2006 23:02 GMT
I'm using Bulk Insert for the first time and have a question.

I'm getting an error message about a field being  truncated:
Bulk insert data conversion error (truncation) for row 2, column 12
(Depleted)

The data type for the "Depleted" column is Char(1).  Looking at the
file, there is indeed only one character in the column.  I'm not sure
how to fix this, or what I can do about it.  Any suggestions would be
appreciated.

Thanks!
Jennifer

The table:

CREATE TABLE [dbo].[parSalesDetailTemp] (
    [parSalesHdrID] [int] NOT NULL ,
    [parSalesDetailID] [int] NOT NULL ,
    [Before] [int] NOT NULL ,
    [Quantity] [int] NOT NULL ,
    [After] [int] NOT NULL ,
    [Promo] [money] NOT NULL ,
    [PromoBefore] [money] NOT NULL ,
    [ItemPrice] [money] NOT NULL ,
    [PromoAfter] [money] NOT NULL ,
    [POSItem] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    [UnitNumber] [int] NOT NULL ,
    [Depleted] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON
[PRIMARY]
GO

The SQL:

BULK INSERT parSalesDetailTemp
FROM '\\wbhq.com\dfsdv\iDataInt\TLDFiles\Extract\SalesDtl.csv'
WITH (FIELDTERMINATOR =',')

The file contents (1st few rows):

8032753,37312006,0,1,0,0,0,4.39,0,"WB-ML",2,N
8032753,37312007,0,1,0,0,0,4.39,0,"WB-ML",2,N
8032753,37312008,0,2,0,0,0,.00,0,"ML-M-COK",2,N
Erland Sommarskog - 29 Dec 2006 23:35 GMT
> I'm using Bulk Insert for the first time and have a question.
>
[quoted text clipped - 6 lines]
> how to fix this, or what I can do about it.  Any suggestions would be
> appreciated.

I was able to successfully insert the sample rows you posted.

I can think of two things:

1) There are trailing blanks.
2) The line terminator is not CR-LF, but only CR or only LF.

Since it was the second line that failed, the first seems more likely to me.

Signature

Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.