vendredi 8 juillet 2016

Excel 2013 VBA to query an SQL Server to lookup items based on cell values

I have an Excel file that has a list of SN's in column A (about 100k). I would like to run a query from within Excel (2013) to an SQL server (2005) to lookup each SN and return the part number and mfg date and place the results in column B and C. Is this possible?

Example worksheet:

   A        B        C
1  I0001
2  I0025
3  J0128
.
. 

Query would lookup SN (column A) from SQL Sever 2005 and fill in column B and C if SN is found in database... results would look like this:

   A        B        C
1  I0001    PN9214   10/20/2012
2  I0025    PN9214   10/31/2012
3  J0128    PN7771   06/06/2015
.
.

The SQL server: db.dbo.table
Fields: SN, PN, mfg_date....

Aucun commentaire:

Enregistrer un commentaire