Re: SQL optimisation, stop the sub query as soon as an error is found

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks for the feedback. Glad I could help! :-)

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net


"obiron via SQLMonster.com" <u56148@uwe> wrote in message
news:9f0bd3df5e4b1@xxxxxx
Damn, that took less than 2 seconds - you really are a guru...

Thanks a lot.

I was doing it the other way because it was originally written with a CTE
rather than a TT

Aaron

TheSQLGuru wrote:
It would really help if you gave table script and sample data with
expected
outcome, but here is a stab:

select *
from #pathway p1
where main_code = 90
and not exists (select * from #pathway p2 where p1.keyfield? =
p2.keyfield?
and p2.main_code = 30 and p2.rank < p1.rank)

that should be MUCH more efficient than your triple hit on the table)

Hi guys,

[quoted text clipped - 71 lines]

Development environment is SQL2005

--
Message posted via http://www.sqlmonster.com



.



Relevant Pages

  • Re: Tracing
    ... To know data changes you need regular triggers or a third-party auditing ... SQL Server MVP ... kgboles a earthlink dt net ...
    (microsoft.public.sqlserver.programming)
  • Re: 2008 Database Engine Tuning Advisor
    ... Kevin G. Boles ... SQL Server MVP ... kgboles a earthlink dt net ...
    (microsoft.public.sqlserver.server)
  • Re: Tracing
    ... DeleteDate columns at the end of each table in my databases and ... SQL Server MVP ... kgboles a earthlink dt net ...
    (microsoft.public.sqlserver.programming)
  • Re: Tracing
    ... Kevin G. Boles ... SQL Server MVP ... kgboles a earthlink dt net ...
    (microsoft.public.sqlserver.programming)
  • Re: 2008 Database Engine Tuning Advisor
    ... Kevin G. Boles ... SQL Server MVP ... kgboles a earthlink dt net ...
    (microsoft.public.sqlserver.server)