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.
| Author |
Topic |
|
ron2112
Starting Member
44 Posts |
Posted - 2008-04-03 : 13:48:13
|
| I'm self-taught on T-SQL so forgive me if this is a dumb question. If I have a stored procedure containing the following...IF [condition] SELECT ...ELSE SELECT ...Would it be more efficient/proper/etc. to break those two SELECTs out into their own SPs and execute them from the IF statement?IF [condition] EXEC [SP]ELSE EXEC [SP]I've got a number of pretty lengthy SPs that I think are pretty tight but if I can make them more efficient by breaking them down into smaller tasks, I'd rather do that.thanks!Ron Moses |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2008-04-03 : 20:47:34
|
| It might be, it might not be. Use the profiler to study the execution plans. I know that sometimes the first time it compiles can dictate the plan for all subsequent executions, which is not always a good thing so splitting up has had advantages. |
 |
|
|
|
|
|