|
|
Question : commandtimeout in vbscript/ado query
|
|
I'm on server 2003 w/sql 2005, with 5 relatively large tables (150,000-500,000 records, 180 columns). I'm working to create a daily process which copies the current data from temp tables to 5 other tables, with exactly the same structure (table1TEMP data into table1). I'm trying to automate this process which is currently working, into a series of vbs scripts. The query below works when in the query editor on the console, but times out when trying to run from vbscript. It takes about 80 seconds to run on the console, and it dies out after about 20 in vbscript...
Here's my vbscript, any idea whether there is a recordset propery that would allow the command timeout to be extended? As noted, I need about 90 seconds or so. Note, the connection is not timing out, its the query command results, not returning fast enough...
simply put, the query truncates the 5 destination tables, then inserts data from the temp table, into the regular table.
Would it be easier to just create a stored procedure to run the query, than to do it this way? that way i would just kick off a stored procedure from vbscript... a thought..
--------------------------------------------------------- Const adOpenStatic = 3 Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection") Set objRecordSet = CreateObject("ADODB.Recordset")
objconnection.ConnectionTimeout = 90
objConnection.Open _ "Provider=SQLOLEDB;Data Source=mcc-csc-04.mcc.del.jpmorganchase.com;" & _ "Trusted Connection=Yes;Initial Catalog=CIASATS;" & _ "User ID=web;Password=webuser;"
objRecordSet.Open "truncate table imsassets truncate table imscontacts truncate table IMSCOSTCENTERS truncate table IMSHOSTNAMES truncate table IMSIPS INSERT INTO IMSAssets Select * FROM IMSAssetsTemp Insert into IMSContacts Select * from IMSContactsTemp INSERT INTO IMSCOSTCENTERS Select * FROM IMSCOSTCENTERSTEMP INSERT INTO IMSHOSTNAMES SELECT * FROM IMSHOSTNAMESTEMP INSERT INTO IMSIPS SELECT * FROM IMSIPSTEMP" , objconnection, adOpenStatic, adLockOptimistic
objrecordset.close -------------------------------------------------------------
|
Answer : commandtimeout in vbscript/ado query
|
|
So add:
objconnection.CommandTimeout = 90
after
objconnection.ConnectionTimeout = 90
|
|
|
|
|