Hi. I am having two main issues. Any help with these would be greatly appreciated.

I have a stored SQL procedure saved in the variable SqlTextFile. The code below is meant to call the SQL server (defined in myConStr), run the stored query, and then copy the results into my excel worksheet.

This code works fine when I run a query that is quick and outputs only 1 table. I am having two issues.

1). When I run this on SQL code that takes perhaps 2 minutes to run, I get a timeout error after 30 seconds. I believe I am seeting the timeout to longer than this, but clearly I am not. Any ideas on why this is?

2). The copying from the recordset at the end will only copy the first table that is output by the SQL query. How do I copy more than 1 table?

objMyConn.ConnectionString = myConStr
objMyConn.CommandTimeout = 90000
objMyConn.ConnectionTimeout = 90000
objMyConn.Open
Dim hFile As Long
hFile = FreeFile
Open SqlTextFile For Input As #hFile
sqlstatement = Input$(LOF(hFile), hFile)
'Set and Excecute SQL Command'
Set objMyCmd.ActiveConnection = objMyConn
objMyCmd.CommandText = sqlstatement
objMyCmd.CommandType = adCmdText
' 'Open Recordset'
Set objMyRecordSet = objMyCmd.Execute
ActiveSheet.Cells(3, 1).CopyFromRecordset (objMyRecordSet)
Close #hFile


Thank you very much for taking the time and helping.