+ Reply to Thread
Results 1 to 4 of 4

Preparing data to insert into SQL table

Hybrid View

godonnygo Preparing data to insert into... 10-06-2007, 05:30 AM
mrice Try somethng like Sub... 10-06-2007, 08:13 AM
godonnygo Cheers for that, what's... 10-06-2007, 09:56 PM
mrice Have a look at ... 10-07-2007, 02:27 PM
  1. #1
    Registered User
    Join Date
    08-05-2006
    Posts
    14

    Preparing data to insert into SQL table

    I've got an excel spreadsheet full of data that I want to insert using SQL into an Oracle database.

    The data is separated into columns. The columns are ID, Name, ***, DOB, Address, Phone.

    I want to be able to get this data to fall into the following statement:
    insert into TABLE
    values (0001,'Robert Harvey','M',18/01/1971,'8 Heversham Grove', 'Melton',96816487);

    There are around 900 records with the data laid out similar to the above fashion. How would I get all these values into individual insert statements?

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Try somethng like

    Sub Test()
    For N = 2 To Cells(65526, 1).End(xlUp).Row
        MySQLSTring = "insert into TABLE values (" & _
        Cells(N, 1) & ",'" & _
        Cells(N, 2) & "','" & _
        Cells(N, 3) & "'," & _
        Cells(N, 4) & ",'" & _
        Cells(N, 5) & "', '" & _
        Cells(N, 6) & "'," & _
        Cells(N, 7) & ");"
    
        'Insert your DB access code here
    
    Next N
    End Sub

  3. #3
    Registered User
    Join Date
    08-05-2006
    Posts
    14
    Cheers for that,

    what's the DB access code though?

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Have a look at

    HTML Code: 

+ 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