> I know nothing about the intricacies of MS SQL but what I think he was
> getting at is that if you use a function in a query it will be evaluated for
> every row which will slow the query down whereas if you use variables which
> are preset to the function value the function is only evaluated once.

Stephen replied with using the dateadd() function instead of direct
date arithmetic.

MSSQL is designed to optimize such queries and not evaluate things
more than it needs to. I believe it might be evaluating the getdate()
for each row sometimes and not others...

However, as I mentioned in my followup message, the slowdown occurs
with literals instead of the getdate() values per my last test. This I
don't understand, as literals should be evaluated only once.

I tried using a work-around that involves a temp table, but it seems
the temp table is going out of scope in my ASP page(ADODB access to
MSSQL)... I'm guessing it might have something to do with some sort of
connection pooling...


-- 
Derek


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to