October 10, 2013 at 11:46 am
In t-sql 2008 r2, can you tell me what performs better from the following two options and why:
1. If parameter value = '1'
goto parm1
else of parameter value = '2'
goto parm2
goto final
parm1:
<do something1>
goto final
parm2:
<do something2>
final:
2. If parameter value = '1'
<do something1>
else of parameter value = '2'
<do something2>
October 10, 2013 at 11:51 am
I don't believe that there's a performance difference. However, I'm not sure why would anyone use so many gotos, seems like spaghetti code for me.
October 10, 2013 at 12:29 pm
I would go for option 2. More concise and less confusing.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
October 10, 2013 at 12:45 pm
wendy elizabeth (10/10/2013)
In t-sql 2008 r2, can you tell me what performs better from the following two options and why:1. If parameter value = '1'
goto parm1
else of parameter value = '2'
goto parm2
goto final
parm1:
<do something1>
goto final
parm2:
<do something2>
final:
2. If parameter value = '1'
<do something1>
else of parameter value = '2'
<do something2>
I agree with the others... there is no real difference in peformance so I'd go with the simplicity and inherent readability of option 2.
However, it may be that neither is actually appropriate. What is the "do something" in each case?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply