+ Reply to Thread
Results 1 to 2 of 2

VBA Insert Stement for SQLServer

  1. #1
    marcmc
    Guest

    VBA Insert Stement for SQLServer

    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

  2. #2
    marcmc
    Guest

    RE: VBA Insert Stement for SQLServer

    got iot but have a syntax error as in 'VBA Syntax' thread above.

    "marcmc" wrote:

    > 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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1