Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm new to SQL Server, just started. I am trying to do a BULK INSERT but it keeps giving the error -

Command is -

SQL
BULK INSERT Astronomy_DB.dbo.Messier_Table
FROM 'f:\testdata.cvs'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)


but it always gives me the error no matter where I put the file:

Msg 4860, Level 16, State 1, Line 1
Cannot bulk load. The file "f:\testdata.cvs" does not exist.


Could someone please give me a clue?
Posted
Comments
PIEBALDconsult 17-Sep-15 20:32pm    
If SQL Server can't give you a clue then neither can we.

Just a rough guess, but since the SQL Server service runs as an account that is not YOU, it doesn't have access to what I assume is a network drive. Copy the file locally to the server and try it from there. I'd be willing to be it works.
 
Share this answer
 
Dave, thank you for the reply. It was actually not a network drive issue - f: was a usb thumb drive I was using. Apparently SQL Server did not like the .csv file extension. I changed it to .dat and had success. the only other problem was the extra commas that Excel put at the each line when I saved as .csv. When I removed those all was well!

Again, thanks for the response.
 
Share this answer
 
Your login should have access to read file on the F drive. Trying moving the file to an alternate drive.

There can be alternates to bulk upload (SqlBulkCopy etc.). Handling BULK Data insert from CSV to SQL Server[^] mentions some of these other approaches.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900