They are two different things. A stored procedure is a compiled SQL statment that runs on your database server; a pass-through query is basically any valid SQL statement that is sent to your database server from Access over an ODBC connection, thereby by-passing the Jet engine entirely, and any operations it would normally perform on a Jet query (e.g., syntax checking/parsing).
Pass-through queries, however, can be a really effective way of executing stored procedures on your database server. For example, if you wanted to get a list of customers from your server, you could create a stored procedure like:
CREATE PROC up_select_customers
AS
SELECT * FROM Customers
then use the following as your pass-through queries SQL statement:
exec up_select_customers
Pass-through queries that return values (SELECT statements), however, are read-only, but you can also execute stored procedures on your server to run DML SQL statments (inserts, updates, deletes) that don't return values.
When using a pass-through query, you'll need to set some additional properties that Jet queries don't require, noteably an ODBC Connect Str property, which can be either a DSN or a string value like:
ODBC;Driver={SQL Server};Server=(local);Database=MotherOfAllDatabas es;UID=sa;PWD=itsasecret
and the Returns Records property (boolean), ODBC Timeout and Max Records (the last two are optional).
Also, you can't create pass-through queries in the QBE grid. Instead, select Query -> SQL Specific -> Pass-Through in the Access query designer and type in your SQL directly. Since your pass-through queries are parsed on the server, however, you might want to create them there using your DBMS client tools, parse them, then copy them and paste them into Access. That way you know they'll run when they hit the server.
As far as performance goes, stored procedures are about as good as it gets, so using pass-through queries to execute them is a great combination. Plus, since you're using a .mdb file (i.e. Jet is present) you can always cache returned data in local Jet tables, and save yourself a bunch of trips to the server.
I've used pass-through queries that execute stored procedures a bunch with SQL Sever, but never with Sybase, so I can't speak to that, but the general principles apply.
HTH,
Bob
|