+ Reply to Thread
Results 1 to 1 of 1

import and export from SQL SERVER to Excel

  1. #1
    Forum Contributor
    Join Date
    10-28-2003
    Location
    Italy
    MS-Off Ver
    11
    Posts
    134

    import and export from SQL SERVER to Excel

    ...need example to import and export from SQL SERVER to Excel via VBA for Excel. Tks for help.

  2. #2
    AA2e72E
    Guest

    RE: import and export from SQL SERVER to Excel

    "sal21" wrote:
    > ...need example to import and export from SQL SERVER to Excel via VBA for Excel.


    You need an ADO recordset object:

    Set RS = CreateObject("ADODB.Recordset")

    You need a connection string:

    Cn = "DSN=??;uid=??;pwd=??;"

    {substitute as necessary, or use other means to connect}

    Next open the recordset object:

    RS.Open "Your SQL statement", Cn

    Now look up CopyFromRecordset in the Excel help files

    Close the recordset object.
    RS.Close
    Set RS = Nothing

+ 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