connect sql databases

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Connect to SQL databases

Connect to SQL databases

resolvedResolved · Medium Priority · Version 2010

Adrian has attended:
Excel VBA Introduction course

Connect to SQL databases

Hello,
I want to create a macro that call's a SQL database or stored procedure in a SQL database to copy in the information when I open the excel sheet, define a variable (for the query/stored procedure) and click a button to inititae the macro.
How do you call a stored procedure or run a query on a SQL database?

Thanks!

RE: Connect to SQL databases

Hi Adrian,

Thank you for the forum question.

And thank you for the nice feedback.

The best way as I told you is to use ADO to create a connection via a provider. You can connect to a query already created in the SQL database or you can write a SQL query in the visual basic editor and then execute the query from Excel.

SQL is very powerful and you are totally in control using SQL to tell Excel which data you want to display in your Excel reports.




Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector


 

Excel tip:

Hiding Formulae in the Formula Bar

It is possible to protect the contents of a cell reference(s) from amendment by applying cell protection. The contents of the cell reference can also be stopped from displaying in the formula bar.

Step 1: Select Format > Cells > Protection.

Step 2: Tick Hidden option. Ensure Locked is ticked

Step 3: Select Tools > Protection > Protect Sheet

(Ensure "Protect worksheet and contents of locked cells" is ticked)


View all Excel hints and tips


Server loaded in 0.05 secs.