This is an update (to https://answers.sqlperformance.com/questions/4799/how-to-improve-this-procedure.html#comment-4810) after implementing the suggestions of @SDyckes2 to build an #TempTable inside the procedure.
Further improvements (seemed) to result from adding PK to the #temptables that the input parameters were inserted into BUT performance (seemed) to diminish from adding a PK to the internally created #TempTable.
Nonetheless I still have two (seeming) problems in which the Est. Rows vs. Actual Rows differ (by 10x underestimated for the insertions into #TempTable and 140X overestimated for the data output).
Thanks in advance for any and all suggestions.
By MikeS 1 asked Nov 13 at 01:03 AM