Re: Prepared TADOQuery Question




I am using Delphi 7 and TADOQuery to attach to my SQL Server 2005.

I have the prepared property set to true, but when using the MS SQL
Profiler, it shows that query gets passed as hardcoded text to a stored
procedure. The profiler results don't change when I open/close the query.

declare @p1 int
set @p1=1
exec sp_prepexec @p1 output,N'@P1 varchar(20)',N'select id, value from table
where value >= @P1 order by value','AREA1'
select @p1

I would have expected something like this for the second call.

exec sp_execute 1, 'AREA2'

Is there any point in using parameterized prepared queries in ADO? Or am I
using the TADOQuery incorrectly?

SQL server converts queries to stored procedures and then caches the stored
procedure for future use. This is one way it executes more efficiently..
Using parameterized queries in Delphi should speed up the conversion but using
Prepare in Delphi doesn't help


--
Brian Bushay (TeamB)
Bbushay@xxxxxxxxx
.



Relevant Pages

  • Re: ADO.NET query execution much slower than SQL Management Studio
    ... When you first start using a new database it creates stats. ... the first few queries run slowly, as will any unique type of query, as it ... Something that would affect the .NET SqlClient but not SQL Mgmt Studio? ... compare this to the profiler command (meaning what is actually run in the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: ADO.NET query execution much slower than SQL Management Studio
    ... Run the query twice from ADO.NET and see ... Stats being compiled on SQL Server ... If you are dynamically adding statements in a sproc, ... sproc versus running the sproc statement from profiler), ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: SELECT MAX(...) performance in SQL Server/ODBC
    ... I tried the Profiler and compared the results and execution plans in the two ... executing the query from C++ code by calling SQLExecDirect. ... > Have you tried using SQL Profiler to profile the events on the server? ...
    (microsoft.public.data.odbc)
  • query in SQL 2005 profiler in wrapped format
    ... In SQL 2005 profiler, the bottom half of each trace window displays the ... actual SQL query in "wrapped" format (e.g., a single line long query is ... where the actual query is displayed in non-wrapped format. ...
    (microsoft.public.sqlserver.tools)
  • Re: DBMS and lisp, etc.
    ... Naively implemented with SQL, again for 10 ... (1 query for the initial orders, 1 query for each order for its ... soon as you upgrade to the SQL database. ... (eq (order-customer orderA) ...
    (comp.lang.lisp)