December 2013
Intermediate to advanced
1872 pages
153h 31m
English
If you call a SQL Server function (for example, suser_name(), getdate()) repeatedly within a procedure or in T-SQL code, you should consider using a local variable to hold the value returned by the function and use the local variable repeatedly throughout your SQL statements rather than repeatedly executing the SQL Server function. This saves CPU cycles within your stored procedure and T-SQL code.
Note
For additional performance-related query recommendations related specifically to how queries are optimized, see Chapter 31.