jenlion
IS-IT--Management
- Nov 13, 2001
- 215
I have a table in SQL that needs to be updated or inserted to based on a given excel sheet.
I need to run this from VBScript and it is possible for there to be thousands of entries in the excel file. In the past, I had a script run and line-by-line from the excel sheet and find and update an existing item or insert a new one. This turned out to be much too slow for practical usage. I changed it to a new script that created a linked server, dumped the excel directly to sql, and ran update/insert statements. This was very fast, which is great.
However, now I need two things: 1. speed, and 2. security. The app calling the vbscript has a connection to sql server that I can use, so no name or password need be stored in the app. And you can bet the user running this will not be sysadmin. Linked servers is out because I can't assume the excel file will be saved on a local drive of the sql server and I don't want to hard-code the name and password of someone with those privileges in the script.
Do I have any good options (in sql 2005) for triggering an add/update query from excel -- one that will run very quickly even for thousands of records? (quickly = less than a couple of minutes, preferably less than a minute, for, say, 100k records).
Code:
[b]Table[/b]
Item Price1 Price2
---- ------ ------
ItemA 3.00 4.00
ItemB 2.99 3.99
Code:
[b]Excel[/b]
A B C
1 Item Price1 Price2
2 ItemA 3.00 10.00
3 ItemB 1.99 3.50
4 ItemC 9.98 25.00
I need to run this from VBScript and it is possible for there to be thousands of entries in the excel file. In the past, I had a script run and line-by-line from the excel sheet and find and update an existing item or insert a new one. This turned out to be much too slow for practical usage. I changed it to a new script that created a linked server, dumped the excel directly to sql, and ran update/insert statements. This was very fast, which is great.
However, now I need two things: 1. speed, and 2. security. The app calling the vbscript has a connection to sql server that I can use, so no name or password need be stored in the app. And you can bet the user running this will not be sysadmin. Linked servers is out because I can't assume the excel file will be saved on a local drive of the sql server and I don't want to hard-code the name and password of someone with those privileges in the script.
Do I have any good options (in sql 2005) for triggering an add/update query from excel -- one that will run very quickly even for thousands of records? (quickly = less than a couple of minutes, preferably less than a minute, for, say, 100k records).