How to import CSV file into MS SQL Server using BULK INSERT statement

How to import CSV file into MS SQL Server using BULK INSERT statement

Jie Jenn

4 года назад

59,206 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Adam Pagan
Adam Pagan - 15.10.2023 19:20

Thank you , super awesome tutorial!! Do you know if there is any way to use a sequence to generate a primary key with this method, instead of inserting the ID inside the CSV?

Ответить
Nitesh Singh
Nitesh Singh - 28.09.2023 12:36

I want to import 15 million records fastly can I do with this method.

Ответить
Prabhakaran
Prabhakaran - 25.05.2023 08:27

Thank you Jie Jenn .

Ответить
Gennaro Violante
Gennaro Violante - 05.04.2023 12:42

can I use the "bulk insert" function to import files with billions of records, file size 272 GB ?

Ответить
Misukoma
Misukoma - 03.01.2023 09:51

Can we use this with 1.7 mil rows in CSV file ? Thank. I used import flat file but it is error when importing.

Ответить
TheJuicerKid_xqcL
TheJuicerKid_xqcL - 19.12.2022 23:47

If my excel files has multiple sheets how can i insert one by one? Thanks.

Ответить
Anthony Norman
Anthony Norman - 27.07.2022 11:59

This works well, i had a couple of issues with my imported data.

1) Date Format in the CSV File had to change from dd/mm/yyyy to yyyy/mm/dd
2) Time Format had to be applied to where the were columns that had Time
3) Some lines at the bottom of data sheet had unwanted information so had to clear that as well

Other than that, i just repeated the steps and imported 1,264,763 rows
Thank You

Ответить
Be Devoted
Be Devoted - 20.06.2022 17:51

indeed one..thank you brother

Ответить
Minh Ngoác
Minh Ngoác - 03.04.2022 18:05

Thank you so much. With love from Vietnam

Ответить
Vic Iwo
Vic Iwo - 10.03.2022 06:47

Great tutorial! Glad I found this.

Ответить
Mezbah Enterprise
Mezbah Enterprise - 10.02.2022 12:35

It's literally incredible! Thanks Jenn. Guys I came across a problem with system error 32 because I didn't close excel during the final command on SQL server. So, if you face the same problem, just close ms excel first.

Ответить
Swapnil Wankhede
Swapnil Wankhede - 08.02.2022 18:25

Hi
Thanks for uploading useful information.
I am getting error saying, incorrect syntax near format.

Could you please advise, what can be reason behind the error?

Ответить
Itishree
Itishree - 21.01.2022 10:30

I don't understand,, why you put 2 in the firstrow word?? Can you please tell me?? Because I'm trying to insert bulk files by watching ur vdo but it's giving me error.. So i thought I've made something wrong in the firstrow place.

Ответить
Zazzy
Zazzy - 04.01.2022 15:07

Hi, maybe you can help me. I get the error message.
Cannot bulk load because the file "\\File01\.....\TextFile1.txt" could not be opened. Operating system error code 5(Access is denied.).

Ответить
Sai krishna Reddy
Sai krishna Reddy - 30.12.2021 12:02

how to load a flat file if the files are enclosed by single or double quotes. For eg:
Id | Name | sal
1 | 'Ram' | 20000
2 | ' krishna' | 10000

When I load the data with the single quotes then in sql table name column values are storing with single quotes for eg:
1 , ' Ram' , 20000
2, ' KRISHNA',2000

THE result should be without quotes.
Please suggest

Ответить
Sreejith Kayes
Sreejith Kayes - 16.11.2021 10:12

Thanks dude, Could you please tell me how to add a csv file into an existing table

Ответить
Smiso Shezi
Smiso Shezi - 10.08.2021 17:10

Thanks a lot man, but now what do you do when you need to import like 100 to 1000 text files? Will you need a 1000 CREAT statements for each text file you will be importing?

Ответить
Archies Shedge
Archies Shedge - 14.07.2021 18:21

I am getting incorrect syntax near FORMAT in SSMS v18.9.1

Ответить
Hamza
Hamza - 22.04.2021 00:45

For whoever gets an error saying:
"Cannot obtain the required interface ("IID_IColumnsInfo") from OLE DB provider "BULK" for linked server "(null)". "

USE:
ROWTERMINATOR = '0x0a'
instead of '\n' and it should work :)

Ответить
incognegro mode
incognegro mode - 18.03.2021 02:16

hell yeah that was useful. im trying to import a dumb csv now. lol

Ответить
Python 360
Python 360 - 22.02.2021 19:49

Hi Jie, can you help advise on how to use a relative path for the file name to import instead of the absolute one? Is it possible?

Ответить
trinhk
trinhk - 30.01.2021 19:32

I get incorrect Syntax "Incorrect syntax near 'FORMAT'". Any idea why?

Ответить
itsdaj
itsdaj - 28.01.2021 19:26

Thanks for the video. Do you know what command would I use to append data to the table? I tried Append and it did not work.

Ответить
Adrian Reyes Hernandez
Adrian Reyes Hernandez - 23.01.2021 01:59

Hi, how do I import a big data, if I have 300,000 rows and some columns have a NULL values? Thanks!!

Ответить
Anwar Mian
Anwar Mian - 04.01.2021 03:36

Excellent Demo.

Ответить
Fumz
Fumz - 23.12.2020 05:49

Super Useful!! Thank you!

Ответить
Diarmuid Brady
Diarmuid Brady - 30.11.2020 18:49

What is jj? It is coming up as an error

Ответить
fowad27
fowad27 - 25.11.2020 05:34

What happens when the csv has more columns than you want to import?

Ответить
Patrick McAuliffe
Patrick McAuliffe - 03.11.2020 07:32

how would you remove doblue quotes from a column?

Ответить
Karan Salekar
Karan Salekar - 11.09.2020 22:08

I get this error with this same query: Incorrect syntax near 'FORMAT'.

Ответить
Chris
Chris - 09.06.2020 18:56

Cool and simple, thanks

Ответить