title: Code reuse and modularity in SQL
body: <p>Is code reuse and modulatiry a good idea for SQL Stored Procedures programming?</p>
  
  <p>And if so, what's the best way to add these features to a SQL stored procedure code base?</p>
  
  <p>I usually create scalar valued functions for tasks that are common and repeated. I find that it eases both development of new procedures similar to existing ones, but also aids a lot in bugtracking and troubleshooting.</p>
  
  <p>I try to stay away from table valued functions though, due to performance issues.</p>
  
  <p>My rule of thumb is that if it is a calculation, and it's used in several places, then I create a scalar valued function.</p>