Hi There
I have the following from a sql profiler trace.
declare @P1 int
set @P1=28
declare @P2 int
set @P2=180150014
declare @P3 int
set @P3=8
declare @P4 int
set @P4=1
declare @P5 int
set @P5=0
exec sp_cursorprepexec @P1 output, @P2 output, N'@P1 varchar(5)', N'SELECT BUSINESS_UNIT, DESCR, DEMAND_DATE, ORDER_NO, OLD_ORDER_NO_XX, CUST_ID, SHIP_CUST_NAME2, SHIP_CUST_NAME1, ADDRESS1, ADDRESS2, ADDRESS3, CITY, DESCR100, ORDER_INT_LINE_NO, INV_ITEM_ID, DESCR40, QTY1, QTY2, REQUEST_DATE, ROUTE_CD, DESCR20 from PS_GOODS_OUT1_JDVW where BUSINESS_UNIT = @P1 order by BUSINESS_UNIT,DEMAND_DATE,ORDER_NO,CUST_ID,ORDER_INT_LINE_NO,DESCR20 ', @P3 output, @P4 output, @P5 output, '00280'
select @P1, @P2, @P3, @P4, @P5
now on profiler this cursorprepexec does over 403 million reads with a duration of over 40 minutes.
When i run the sql in query analyzer even for bigger branches it takes seconds with a few thousand reads.
Can someone please tell me why when it runs via cursorprepexec via the application it brings production to a grinding halt but not when simply run through analyser.
P.S i run it at the same transaction isolation level and the same database , at the same time of the day.
PLEASE HELP
Thanx

Query runs long in profiler but quickly in Query Analyser ?
wooks