Re: How to get populate a EXCEL table from an SQL server ?
Originally posted by ontheDB
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 ?
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
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 .