Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Performance benefits of sprocs

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-09-12 : 00:14:40
Mark writes "A few questions for you... 1)Does SQL have to re-parse a sproc if it can't find it in cache? 2) If the sproc conditionally executes one of two separate and dissimilar queries, are the query plans for both branches of the condition pre-optimized? If they both are not, which is and why? An example below...thanks!

create procedure usp_MySproc
@flag char(1),
@crit varchar(20)
as
if @flag = 'A'
select a.col 1
from tableA a
join tableB b
on a.col1 = b.col1
and a.col3 = @crit

if @flag = 'B'
select c.col1, d.col3, d.col5
from tableC c
left outer join tableD d
on c.col1 = d.col5
where d.col7 != @crit
order by d.col5 desc

return"
   

- Advertisement -