The phantom truncation.

    Date: 01/24/06 (SQL Server)    Keywords: sql

    I'm hoping someone knows, because I've been looking on the Internet for the past hour and a half. I have seen this question asked many, many times, but I have no yet seen an answer. sorry if I've asked this exact question before. Maybe someone's new here and knows.

    I'm getting the following output:

    Server: Msg 4863, Level 16, State 1, Line 1
    Bulk insert data conversion error (truncation) for row 1, column 10 (underdecis).
    Server: Msg 4863, Level 16, State 1, Line 1
    Bulk insert data conversion error (truncation) for row 2, column 11 (yesno).
    Server: Msg 4863, Level 16, State 1, Line 1
    Bulk insert data conversion error (truncation) for row 3, column 10 (underdecis).
    Server: Msg 4863, Level 16, State 1, Line 1
    Bulk insert data conversion error (truncation) for row 4, column 11 (yesno).
    Server: Msg 4863, Level 16, State 1, Line 1
    Bulk insert data conversion error (truncation) for row 5, column 10 (underdecis).
    [etc., etc. ad nauseam]

    ...from the following command:

    bulk insert edi.dbo.hdstaging2 from '\\tesla\sql data\load\hd.txt' with ( DATAFILETYPE = 'char')



    Here's the data that corresponds to the above error messages:

    HD	030		HLT	NO PREF	FAM		
    HD	030		HLT	NO PREF		  
    HD	030		HLT	NO PREF		                                   
    HD	030		HLT	NO PREF	EMP		                           
    HD	030		HLT	NO PREF	FAM		


    Unfortunately, the unprintables are being unprintables; the column separator is chr(9), and there are two chr(9)s at the end of each row (for various reasons far too long to go into here). There are also two chr(9)s between "30" and "HLT", so I can't simply strip out every instance of two chr(9)s sitting close together.

    Now, note the (lack of) correlation between the error messages and the data. Just another confusing piece of the puzzle.

    I have gathered from today's reading that this is somehow related to the fact that I have fewer actual data items than I do columns in the table into which I'm inserting data. All well and good, I can drop it into a staging table with fewer columns and work from there, with one problem: I have different numbers of populated data columns in different lines.



    Does anyone have any idea how to get around this error? "Don't use bulk insert" is the obvious one, but that leads to a whole rash of other questions. If necessary, I'll elucidate those in another post, but got cut off halfway through asking them and had to take an impromptu meeting, and now have no time to finish before leaving work. Salud!

    Thanks in advance.

    Source: http://community.livejournal.com/sqlserver/41237.html

« ...but I'm NOT... || Newbie stored procedure... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home