Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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.

Cheers,

-Vijay G
__________________
- Vijay G
Reply With Quote
  #2 (permalink)  
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
Default

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]
) ON [PRIMARY]

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
) ON [PRIMARY]



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:21 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.