Accessing data in SQL Server via VBA

yassem

New Member
Joined
Jul 20, 2012
Messages
6
I am currently writing aset of macros thatare supposed to get data from an SQL server, paste it in two sheets and then mash it up and send. Point 2. and 3. is easy but I have no experience with SQL whatsoever, hence thequestion.

I've read several other threads on the subject on this forum and elsewhere, but none of them have given my a desicive sollution.

From what I understand to connect I'd need Provider, Catalog, Data source as well as UserID and Passwor, let's say I now all of these : )

My SQL is as follows:
Code:
SELECT t.ni
a.namei
a.surrnamei
b.cityi
b.streeti
c.numberi
c.date
FROM bwe.ki
where date=

and simillar for the other table, how am I supposed to write it?

I would greatly appreciate a swift anwser and thanks in advance : )
 
Hi yassem,

First of all you have to add the reference of Microsoft Active X data objet in this project and then you can use this code given above.

in the provider you can use SQL server native client 10.0 or you can check from administrative tools in control panel.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,215,460
Messages
6,124,949
Members
449,198
Latest member
MhammadishaqKhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top