ADO MS-SQL locks on TempDB from read-only SQL Queries via TADOQuery

Client-server Delphi 5 app, locking problems in TempDB Apparently due to ADO
causing
MSSQL creating stored procedures for certain queries in my app.  The app is
creating locks in TempDB that are causing contention problems with other
apps.
I'm running ADO 2.6.

These are normal SQL queries that return a result set.  I am using a
TADOQuery
within Delphi 5.  I run all my ADO queries through a single ADO Connection
object that I create in a separate data module.  This ADO connection uses a
UDL
file to provide the ADO connect string.

I can "fix" the problem by changing the UDL file so that the "Use Procedure
for
Prepare" option is off.  I would prefer not to do this if there is another
way
to keep SQL Server and ADO from placing locks on TempDB.

I could also fix the problem by using stored procedures to retrieve the
recordsets.  I'd prefer not to do that either, as I prefer the simplicity of
having the SQL statements in the code, and there is no performance reason to
use
stored procedures in this app.

How can I keep these locks from being placed on TempDB by this type of SQL
Query?  Is there a per-statement option I can set in TADOQuery that would
keep
the locks from being placed on TempDB?  This app is causing contention with
other apps
that also make use of TempDB.  This issue did not occur at all in BDE using
the
BDE-ODBC passthru to talk to MS-SQL, so it appears that ADO may be doing
some
"helpful" things behind the scenes that cause the locks on TempDB.

Below is one example of a SQL query that causes this behavior.  When
actually
running this from within my Delphi app, the commented-out lines that contain
parameters are included in the query.

/*
Select a summary for transmittal for an accounting date range
This joins the receipt, receiptitem, and feecode tables to produce counts
and summaries by fee category
*/
select fee_cat_cd, count(*) as 'fee_tot_ct', sum (rci_qty_nu *
convert(int,rcp_typ_cd) * -1) as 'fee_void_ct', sum(rci_qty_nu) as
'fee_net_ct', sum(rci_ext_price) as 'fee_net_amt', fee_rev_cd
from receipt a,  receiptitem b, feecode c
/* where a.rcp_site_id = :rcp_site_id  */
/* and rcp_reg_nu =  :rcp_reg_nu  */
where a.rcp_site_id = b.rci_site_id
and a.rcp_reg_nu = b.rci_reg_nu
and a.rcp_acctg_dt = b.rci_acctg_dt
and a.rcp_rcp_nu = b.rci_rcp_nu
and (a.rcp_site_id = c.fee_site_id  or c.fee_site_id = 'ALLSITES')
and (a.rcp_reg_nu = c.fee_reg_nu OR c.fee_reg_nu = 0)
and b.rci_fee_type = c.fee_type_cd
/* and a.rcp_acctg_dt between :rcp_acctg_beg_dt and :rcp_acctg_end_dt  */
group by rcp_site_id, rcp_reg_nu, rcp_acctg_dt, fee_cat_cd, fee_rev_cd
order by rcp_site_id, rcp_reg_nu, rcp_acctg_dt, fee_cat_cd

The above query returns a result set that looks like this:

fee_cat_cd                          fee_tot_ct  fee_void_ct fee_net_ct
fee_net_amt           fee_rev_cd
----------------------------------- ----------- ----------- ----------- ----
----------------- ------------------------------
Abstract of Driving Record          7           0           39
175.5000              106-060-421-0008
Application for Occupational DL     2           0           4
100.0000              106-040-254-0005
License Fee                         1           0           1
5.0000                106-040-254-0005
NSF Checks                          1           0           1
40.0000               106-040-254-0005
Application for Occupational DL     1           0           1
25.0000               106-040-254-0005
Individual Addresses                1           0           1
2.0000                106-060-421-0008
Reinstatement Fee @$150.00          1           0           1
150.0000              106-040-254-0018
Hearing Fee                         1           0           1
100.0000              106-060-254-0020

When I run the sp_lock procedure to see locks, following is what I get,
showing
the locks created by this query:

sp_lock
spid   locktype                            table_id    page        dbname
------ ----------------------------------- ----------- ----------- ---------
------
16     Sh_intent                           704005539   0           master
16     Ex_extent                           0           400         tempdb
17     Ex_extent                           0           360         tempdb
17     Ex_extent                           0           368         tempdb
17     Ex_extent                           0           376         tempdb
17     Ex_extent                           0           384         tempdb
17     Ex_extent                           0           392         tempdb
17     Next_extent                         0           336         tempdb
17     Prev_extent                         0           256         tempdb
17     Ex_page                             1           3           tempdb
17     Ex_page                             1           40          tempdb
17     Ex_intent                           3           0           tempdb
17     Ex_page                             3           317         tempdb
17     Ex_table                            5           0           tempdb
17     Ex_page                             6           104         tempdb
17     Ex_page                             6           105         tempdb
17     Ex_page                             6           106         tempdb
17     Ex_page                             6           112         tempdb
(18 row(s) affected)

Also, there are a bunch of temporary tables created as well.

select * from sysobjects
name                           id          uid    type userstat sysstat
indexdel schema_ver refdate
------------------------------ ----------- ------ ---- -------- ------- ----
---- ---------- ---------------------------
#oledbjdanie1_________00001339 738153725   2      P    0        4       0
0          2001-06-15 12:14:18.417
#oledbjdanie2_________00001339 754153782   2      P    0        4       0
0          2001-06-15 12:14:19.260
#oledbjdanie3_________00001339 770153839   2      P    0        4       0
0          2001-06-15 12:14:19.323
#oledbjdanie4_________00001339 786153896   2      P    0        4       0
0          2001-06-15 12:14:19.497
#oledbjdanie5_________00001339 802153953   2      P    0        4       0
0          2001-06-15 12:14:19.510
#oledbjdanie6_________00001339 818154010   2      P    0        4       0
0          2001-06-15 12:14:19.650
#oledbjdanie7_________00001339 834154067   2      P    0        4       0
0          2001-06-15 12:14:19.777
#oledbjdanie8_________00001339 850154124   2      P    0        4       0
0          2001-06-15 12:14:19.963
#oledbjdanie9_________00001339 866154181   2      P    0        4       0
0          2001-06-15 12:14:30.917
#oledbjdanieb_________00001339 882154238   2      P    0        4       0
0          2001-06-15 12:14:41.433
#oledbjdaniec_________00001339 898154295   2      P    0        4       0
0          2001-06-15 12:14:41.480
#oledbjdanied_________00001339 914154352   2      P    0        4       0
0          2001-06-15 12:14:45.590
#oledbjdaniee_________00001339 930154409   2      P    0        4       0
0          2001-06-15 12:14:46.060

Any help or insights appreciated.

Jim Daniels