Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Query vs SELECT statements

Status
Not open for further replies.

wvandenberg

Technical User
Joined
Oct 24, 2002
Messages
125
Location
CA
I would like to ask for some advice about the performance of stored queries vs. SELECT statements and when/where to use each.

Which of the following scenarios would be faster/better/more efficient/preferred by real programmers (unlike myself)
Code:
    strSQL = "SELECT DISTINCT ANALYTE, AnalyteName, pkAnalyteID, ReportingUnitsDescription " & _
            "FROM tblImportALS, qryAllAnalytes " & _
            "WHERE AnalyteName Like ANALYTE " & _
            "And ReportingUnitsDescription Like UNITS"
    Set rst = db.OpenRecordset(strSQL)

vs. (assuming the SQL of Qry1 is the same as strSQL)

Code:
    Set rst = db.OpenRecordset("Qry1")

Also, is it faster/better/more efficient/preferred by real programmers (unlike myself) to use a stored query as the control source for a combo box rather than a Select statement?

Any comments or advice is appreciated.

Wendy

 
IMHO, the performance will be not be much different unless the recordset is quite large. I expect the saved query will "compile" to provide greater performance.

Regarding the Row Source for a combo or list box (or even a form's Record Source). If you create a query with SQL of:
Code:
SELECT msysObjects.*
FROM msysObjects
WHERE (((msysObjects.Name) Like "~sq_*"));
You will see that most sql statements are actually saved queries.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top