Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    102

    Unanswered: How to get populate a EXCEL table from an SQL server ?

    Hi,

    How would you populate a table from an sql server ?

    I'm not that familiar w/ Excel,

    Where would I put my connection/SQL statements ?


    e.g.

    Set cmd = CreateObject("ADODB.Command")
    Set rs = CreateObject("ADODB.Recordset")
    Set cn = CreateObject("ADODB.Connection")
    cn.Provider = "SQLOLEDB"
    cn.ConnectionString = "server=blah;database=blah;uid=blah;pwd=blah"
    cn.ConnectionTimeout = 600
    cn.Open

  2. #2
    Join Date
    Sep 2003
    Posts
    102

    Re: How to get populate a EXCEL table from an SQL server ?

    Originally posted by ontheDB
    Hi,

    How would you populate a table from an sql server ?

    I'm not that familiar w/ Excel,

    Where would I put my connection/SQL statements ?


    e.g.

    Set cmd = CreateObject("ADODB.Command")
    Set rs = CreateObject("ADODB.Recordset")
    Set cn = CreateObject("ADODB.Connection")
    cn.Provider = "SQLOLEDB"
    cn.ConnectionString = "server=blah;database=blah;uid=blah;pwd=blah"
    cn.ConnectionTimeout = 600
    cn.Open
    I want to automate a query, so that I can run it with the push of a button.
    Is this as easy as I suspect ?
    I start recording of a Macro
    I just go to
    DATA -> Get External Data - > New Database Query
    enter my SQL 'select' statements.
    and populate the corresponding Excel sheets.
    And stop the recording of a Macro .

Posting Permissions

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