Cannot fetch a row from OLE DB provider “BULK” for linked server “(null)”

前端 未结 12 1516
粉色の甜心
粉色の甜心 2021-02-18 13:24

I try to load my database with tons of data from a .csv file sized 1.4 GB. But when I try to run my code I get errors.

Here\'s my code:

USE [Intradata N         


        
相关标签:
12条回答
  • 2021-02-18 13:38

    This might be a bad idea with a full 1.5GB, but you can try it on a subset (start with a few rows):

    CREATE TABLE CSVTest1
    (Ticker varchar(MAX) NULL,
        dateval varchar(MAX) NULL,
        timevale varchar(MAX) NULL,
        Openval varchar(MAX) NULL,
        Highval varchar(MAX) NULL,
        Lowval varchar(MAX) NULL,
        Closeval varchar(MAX) NULL,
        Volume varchar(MAX) NULL
    )
    

    ... do your BULK INSERT, then

    SELECT MAX(LEN(Ticker)),
        MAX(LEN(dateval)),
        MAX(LEN(timevale)),
        MAX(LEN(Openval)),
        MAX(LEN(Highval)),
        MAX(LEN(Lowval)),
        MAX(LEN(Closeval)),
        MAX(LEN(Volume))
    

    This will help tell you if your estimates of column are way off. You might also find your columns are out of order, or the BULK INSERT might still fail for some other reason.

    0 讨论(0)
  • 2021-02-18 13:40

    I had same issue.

    Solution:

    Verify the CSV or textfile in text editors like notepad+. Last line might be incomplete. Remove it.

    0 讨论(0)
  • 2021-02-18 13:42

    I got this exception when the char field in my SQL table was too small for the text coming in. Try making the column bigger.

    0 讨论(0)
  • Resurrecting an old question, but in case this helps someone else: after much trial-and-error I was finally (finally!) able to get rid of this error by changing this:

    ROWTERMINATOR = '\n'
    

    To this:

    ROWTERMINATOR = '0x0A'
    
    0 讨论(0)
  • 2021-02-18 13:47

    I got this error when my format file (i.e. specified using the FORMATFILE param) had a column width that was smaller than the actual column size (e.g. varchar(50) instead of varchar(100)).

    0 讨论(0)
  • 2021-02-18 13:53

    i just want to share my solution to this. The problem was the size of table columns, use varchar(255) and all should work.

    0 讨论(0)
提交回复
热议问题