0

Trying to upload a json response from my blog storage into my sql table raw. Established the connection, so that is not a problem, however when I try to run

BULK INSERT dbo.httpjson

FROM 'xxxxxx [path]'

WITH ( DATA_SOURCE = 'MyAzureBlobStorage');

I get

Msg 4866, Level 16, State 1, Line 1
The bulk load failed. The column is too long in the data file for row 1, column 1. Verify that the field terminator and row terminator are specified correctly.

Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.

Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

I cannot find out what I am doing wrong, as I am just following MS tutorial: https://learn.microsoft.com/en-us/sql/relational-databases/json/import-json-documents-into-sql-server?view=sql-server-ver16

I hope someone can help me out as I am finally very close to my goal!

  • Can you attach the json file with couple of records? Also the table structure. – AnuragSharma-MSFT Jun 13 '22 at 09:17
  • Hi @LasseRindom, did the suggested solution work for you? Do let me know if it solved your problem else share more details so I can troubleshoot or else do accept it for helping other community members. – Kartik Bhiwapurkar Jul 25 '22 at 04:46

1 Answers1

0

Try by providing Field and Row Terminators to datafile

One approach to tell the program that reads the data file where one field or row stops, and another field or row begins is with terminating characters. With the help of the terminating characters, you are able to indicate the ending of each field and each row in a data file.

FIELDTERMINATOR: - It specifies the character or symbol that indicates the end of one field and start of a new field. '\t' is default field terminator.

ROWTERMINATOR: - It specifies the character or symbol that indicates the end of one row and start of new row. '\r\n' is default field terminator.

Code Example: -

BULK INSERT myDepartment 
FROM  'C:\myDepartment-c-t.txt'  
WITH ( DATAFILETYPE = 'char', FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' 
);

For reference regarding the above for similar thread, kindly find the link below: -

"Column is too long" error with BULK INSERT

Also, find the below documentation link below for more information: -

https://learn.microsoft.com/en-us/sql/relational-databases/import-export/specify-field-and-row-terminators-sql-server?view=sql-server-ver16

Kartik Bhiwapurkar
  • 4,550
  • 2
  • 4
  • 9