Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 7th, 2003, 09:41 PM
Registered User
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pass-through queries vs stored procedures

I would like to know if pass-through queries in Access 97 are the same as stored procedures. If not which is more efficient I have a font end application in Access '97 that has to connects to sybase database.

Thank you

Old October 8th, 2003, 01:34 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

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
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.



Old October 8th, 2003, 02:00 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

The succinct formula might be something like:

Pass-through queries originate on the client; stored procedures originate on the server. Combined, they provide an excellent mechanism for client/server data exchange.

Similar Threads
Thread Thread Starter Forum Replies Last Post
STORED PROCEDURES shazia1 SQL Server ASP 7 September 26th, 2007 06:11 AM
stored procedures thillaiarasu ASP.NET 2.0 Basics 2 May 3rd, 2007 07:55 AM
Converting Access Queries Into Stored Procedures markw SQL Language 1 March 15th, 2005 11:49 AM
SQL Pass though parameters to stored procedures blinton25 SQL Server 2000 3 March 29th, 2004 02:49 PM
Using Stored Procedures lintacious Classic ASP Basics 1 August 12th, 2003 04:06 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.