Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
| Search | Today's Posts | Mark Forums Read
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 28th, 2003, 02:33 PM
Friend of Wrox
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default BCP error while importing data from a text file

Hi All,

I do have a query here. Please help.

When I used BCP to import data from datafile to a table on sqlserver, I do get this error. Please let me know what could be wrong with it.

Starting copy...
SQLState = 22001, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]String data, right truncation
0 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.): total 78

Command I used is...
bcp DBNAME.OWNER.TABLENAME in sys.log.2003-11-01.csv -c -SSERVERNAME -Uxxxx -PXXXX

I have a file generated everyday (tab-column delimiter and newline-Row Delimiter) with the filename in the format(sys.log.yyyy-mm-dd.csv where dd is the previous day) given above in the command.

What I am trying to do is to automate the process of importing all the files to the sql server as a daily scheduled process/job and at the end of the month another job would analyse the data populated in the table and generate a report.

Please advise. New ideas are most welcome.

Thanks for help in advance.


-Vijay G
- Vijay G
Old December 15th, 2003, 09:16 AM
Registered User
Join Date: Dec 2003
Location: WInter Park, FL, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Here is an error that I caused using 'BCP in.'

SqlStatus = s1000
NativeError = 0
Error: Unexpected EOF in BCD data-file

CREATE TABLE [dbo].[Systems] (
    [System_ID] [int] IDENTITY (1, 1) NOT NULL ,
    [SystemType] [char] (12) NULL ,
    [SysNumber] [char] (12) NULL ,
    [SysAddr] [char] (12) NULL ,
    [StationID] [char] (12) NULL ,
    [Id] [char] (12) NULL ,
    [Pims] [char] (8) NULL ,
    [Location] [varchar] (35) NULL ,
    [Platform_Desc] [varchar] (35) NULL ,
    [Platform_ID] [varchar] (35) NULL ,
    [Platform_Call] [varchar] (35) NULL ,
      [TestNumber] [int]

The trouble was in [TestNumber], or maybe Nulls preceding it.
If [TestNumber] was in the last column or next to last column an error was produced.

When [TestNumber] was moved just past System_Id, the BCP 'in' worked well!

CREATE TABLE [dbo].[Systems] (
    [System_ID] [int] IDENTITY (1, 1) NOT NULL ,
      [TestNumber] [int],
    [SystemType] [char] (12) NULL ,
    [SysNumber] [char] (12) NULL ,
    [SysAddr] [char] (12) NULL ,
    [StationID] [char] (12) NULL ,
    [Id] [char] (12) NULL ,
    [Pims] [char] (8) NULL ,
    [Location] [varchar] (35) NULL ,
    [Platform_Desc] [varchar] (35) NULL ,
    [Platform_ID] [varchar] (35) NULL ,
    [Platform_Call] [varchar] (35) NULL

Similar Threads
Thread Thread Starter Forum Replies Last Post
Text file importing & data processing jarpola Excel VBA 0 January 16th, 2007 10:27 AM
BCP Error while importing data from a textfile happygv SQL Server 2000 5 October 6th, 2006 02:07 AM
Importing a text file DBN Beginning VB 6 6 April 24th, 2006 02:52 PM
Importing data from a text file nav PHP How-To 2 March 7th, 2005 02:42 PM
Problem importing text file manuel Access 3 April 7th, 2004 09:36 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.