0

I am trying to bulk load from a CSV file to an SQL Server (both Excel and SQL Server are sitting on my laptop). I am doing this via Excel VBA using the "bulk insert" statement. I keep getting a run-time error of invalid object name for my table.

  • I have tested the SQL in studio management and it works fine
  • The table name is definitely correct
  • I have tested using the different file formats and I get same error
  • "insert into..." statement works fine from Excel VBA just not the "BULK INSERT"
connServer.Open "Provider=SQLOLEDB;Data Source=" & pstrServer & ";Initial Catalog=" & pstrDBS & ";integrated security=sspi;"

strSQLQuery = "BULK INSERT tbl_q_member " & _ "FROM 'C:\test\bulk.csv' " & _ "WITH (FIRSTROW = 2, FIELDTERMINATOR = ',',ROWTERMINATOR = '\n', TABLOCK)"

connServer.Execute strSQLQuery

The runtime error is

'-2147217865 (800440e37)

Invalid object name 'tbl_q_member'

Dale K
  • 25,246
  • 15
  • 42
  • 71
Ron
  • 1
  • 1

0 Answers0