BULK INSERT

Today I needed to import a csv file into SQL, a task I've done hundreds of times. But it's not my favorite. The wizard is a little clunky and if the data isn't in great shape I get errors. 

Today I tried BULK INSERT and it seemed to go great. I'll document the syntax below (much easier than looking the syntax up again), and I'll add notes as I go if I find anything worth reporting. 

You'll need to create 'myTable' beforehand

bulk insert myTable from 'd:\myCSV.csv' with (fieldterminator=',')

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences