Sample Code Request for Importing SQL Tables to Excel

S

Sandra Poh

Hi, currently, I am using Excel 2000. I would like to do the below in VBA. I
am new in SQL Programming in VBA. To help you to understand myself better, I
have been programming in VBA for Excel quite sometimes. But for the below, I
am totally new.
Pls help me. It is urgent.

01) Check that a local pc connected to an SQL Server (This server is located
in my
office) successfully.
02) Connect to the SQL Server.
03) Open the database.
04) Open a table in this database.
05) Extract this table.
06) Copy all extracted records and paste in one worksheet in my Excel File.
07) Close the table.
08) Close the database.
09) Close the connection.

You may reply to my below email addresses.

01) [email protected]
02) [email protected]

Thanks and Best Regards
Sandra Poh
 
H

Hru48

Sandra,

I may of missed the point but if your using sql server could you not
just run a select * (your table name) and 'save results to file' as a
txt file and then import the text file into excel?

HJ
 
Top