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?
-
@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?– lifeisajourneyOct 29, 2022 at 2: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?– lifeisajourneyOct 29, 2022 at 2:14
-
2@lifeisajourney, yes. Search the internet for "parameter sniffing".– Dan GuzmanOct 29, 2022 at 3:35