If a parameter that is passed to stored procedure is assigned to a local variable and the local variable is used inside the stored procedure logic, will that affect the execution plan in any way? Is it a good practice to use them?
Asked
Active
Viewed 23 times
0
-
@ErikDarling It kinda does. I just realized I missed an important piece in the question. When I pass a parameter into the stored procedure and assign it to a variable and use that variable instead of the parameter inside the stored procedure logic, will the execution plan get affected in anyway? – lifeisajourney Oct 29 '22 at 02:06
-
The examples in the link you provided seem to be for stand alone queries. Does it work the same way for stored procedures as well? – lifeisajourney Oct 29 '22 at 02:14
-
2@lifeisajourney, yes. Search the internet for "parameter sniffing". – Dan Guzman Oct 29 '22 at 03:35