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'

11
  • Is the query working in SSMS ? Commented Aug 5, 2019 at 6:52
  • Yes it is, that is the puzzling thing. Commented Aug 5, 2019 at 6:55
  • Try "BULK INSERT [tbl_q_member] " Commented Aug 5, 2019 at 7:02
  • Still the same error message unfortunately. Commented Aug 5, 2019 at 7:04
  • What happens when you try something like BULK INSERT [DBNAME].[dbo].[tbl_q_member] Commented Aug 5, 2019 at 7:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.