© Lisa Bohm 2020
L. BohmRefactoring Legacy T-SQL for Improved Performancehttps://doi.org/10.1007/978-1-4842-5581-0_6

6. Stored Procedures

Lisa Bohm1 
(1)
Chardon, OH, USA
 

In Chapter 2, we went ahead and documented a stored procedure used to call data for a report. The proc was called dailySummaryReportByMonth. Let’s review the documentation from Chapter 2; then we can start to rewrite the stored procedure. When we look at the data calls, we see six calls to the dbo.Posts table. There’s a good chance we can reduce the number of calls to that table. The proc also uses both a temporary table and a table variable.

Temporary Tables vs. Table Variables

There is a lot of debate between whether to use table variables or temporary tables. There can be issues ...

Get Refactoring Legacy T-SQL for Improved Performance: Modern Practices for SQL Server Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.