我有一个存储过程,当从sql Server Management Studio运行时,这样调用时一直需要5秒才能运行.
exec dbo.MyStoredProc '2009-04-30 00:00:00','2009-04-30 20:00:00'
当通过VBA从excel电子表格调用时,需要6分钟(不包括将记录集复制到工作表所花费的时间.VBA只是简单地使用ADO连接来返回记录集.不幸的是,Excel方法是客户端要求我无法摆脱它.
Public Function Generatesql(strQueryName As String) As Recordset Dim rs As Recordset,cm As Command,dbsConn As Connection Set dbsConn = New ADODB.Connection dbsConn.Open Configuration.Range("ConnectionString") Set cm = New ADODB.Command With cm .CommandText = strQueryName .CommandType = adCmdStoredProc .CommandTimeout = 300 .ActiveConnection = dbsConn Set rs = .Execute() End With Set Generatesql = rs End Function
有谁知道为什么会发生这种情况或者我如何开始追踪正在发生的事情?
谢谢,
史蒂夫