Hi all,
Steps to reproduce
I have created sample table “CSVTest” on in db, having fields as id, first name and last name.
To import data using bulk insert please use following SQL. I have shared “sample.txt”.
BULK INSERT CSVTest
FROM '\\mymachine\import\sample.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = ''
)
--- Data in Sample.text (NOTICE: NEWLINE at the end of file) --
1,James,
2,BK,
------- End of data----
It inserts data properly with 2 rows.
Try the same query, but change data as
--- Data in Sample.text (NOTICE: NO NEWLINE at the end of file & NO data at last row last column) --
1,James,
2,BK,
------- End of data----
PROBLEM: Only first row get inserted and second row is not.
Try the same query, but change data as
--- Data in Sample.text (NOTICE: NO at the end of file & NO data at last row last column) --
1,James,
2,BK,SD
------- End of data----
It inserts 2 rows 🙂
One way to solve problem is to add NEWLINE at end, but this is fix and not solution.
Are there any other ways to solve this ?