Best Practices while creating Stored Procedures

1. SET NOCOUNT ON: Always use ‘SET NOCOUNT ON’ statement at the begening of your code inside the SP to reduce unnecessary network round trips. 2. PARAMETER SNIFFING: Do not use SP parameters directly within the WHERE clause of SQL statements. This may cause the case of Prameter Sniffing. To avod this assign the parameter values to local variables and then use them with SQL queries. 3. Use table variables: Try to use table variables instead of temporary tables inside the SP to cache small record sets whenever possible. 4. Use of Temp Tables: If you think that the temporary… Read more