VBA Insert Stement for SQLServer

M

marcmc

I have data as follows on EXCEL:

ColA ColB
MARC 123
marc1234 234
marc1235 555/0

I have a SQL table with the same structure. I want to insert the range.
I tried:

Dim cName1, cName2 As Variant
cName1 = Range("A")
cName2 = Range("B")

sq = "Insert into marc_temp_excel (ColA, ColB) values (cName1, cName2)"
Set r = c.Execute(sq)
c.Close

MsgBox ("marc_temp_excel Table Successfully Updated.")

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top