-3

I am trying to BULK INSERT a csv file to my SQL Server.

Using code I found on this SO question, I ran:

BULK INSERT Temp 
FROM 'c:\csv\student.csv '  
WITH ( 
       FIELDTERMINATOR = ',', 
       ROWTERMINATOR   = '\n', 
       FIRSTROW        = 2 
     ) 

I got this error:

Msg 208 , Level 16 , state 82 , Line 1
Invalid object name 'Temp' .

What can I do?

6

Your error message means the object can't be found in the context of the session where you're executing your BULK INSERT. This could be because...

  1. The object does not exist and needs to be created. Try CREATE TABLE [Temp] ( ...
    • Also check for typos, did you mean to insert into Temp2 instead?
    • You may need to specify the schema name. Are you trying to insert into foo.Temp instead of dbo.Temp?
  2. You are connected to the wrong database OR server OR are using the wrong credentials.
    • Do you get the same error message when you run select top(1) * from [Temp]; In the same session where you got the error message the first time?

Other reading:

Not the answer you're looking for? Browse other questions tagged or ask your own question.