I'm using this query via e vb ado.

note:

-all fields concerned in inner join are indexed.
-only that when launching the command via vb code to the query is slow (perhaps 3 or 5 minutes )!!!!!!!

-if the launch itself on query sql in Sql Server Mangement Express runs in 1 or 2 seconds !!!!!!!!!!!

-i want to read all records in read mode

-xxxxx is the ip where the client is installed sql express

my code is:

SSQL = "Select * FROM (INNER JOIN BRANCHES ON DATA SPORTELLI.SPORT = DATI.PROVA2)" & _
"INNER JOIN AREA_TERR ON SPORTELLI.REGIONE = AREA_TERR.COD_AREA ORDER BY AREA_TERR.COD_AREA, DATI.PROVA3"

CNSQL1.Execute sSQL, adOpenForwardOnly, adLockReadOnly

Public Sub APRI_CONNESSIONI_SQL1 ()

On Error GoTo error
'CNSQL1.CursorLocation = adUseClient
'CONNECTION TREVIEW
'Set CNSQL1 = New ADODB.Connection

CNSQL1.Open "Provider = SQLOLEDB.1; Password = sal21; Persist Security Info = True; User ID = sa; Initial Catalog = DB_ *****; Data Source = xxxxx \ SQLEXPRESS"

Exit Sub 'exit from the application,
'benefit would be the next code
'been executed
error:
MsgBox "Error number:" & CStr (Err.Number) 'is used to convert CStr
'in a string
MsgBox "Description:" & Err.Description
MsgBox "source of error:" & Err.Source

End Sub

ahhhhhhhhhhhhhh
add ...
that if I run the query via Mangement Sql Server Express installed where the application for risiedee sql express has a lightningr, but if I run away Mangement Sql Server Express installed on another computer (always using the same instance and db) the query is very very slow!!!!!!!!!!!!!

????????????
Edit/Delete Message