title: SQL Server 2008 R2 Express: way to convert NULL's from Joins to zeros
body: <p>I have 2 tables I'm trying to join in <code>SQL Server</code>.  Table one is a list of <code>salesId</code>'s and table two is a list of average sales per month by <code>salesId</code>.</p>
  
  <p>Table1 :</p>
  
  <pre><code>SalesId
   0001
   0004
   0345
   1009
   2290
   ....
  </code></pre>
  
  <p>Table2:</p>
  
  <pre><code>SalesId    AvgMnthSales
   0001       22253.34
   0002        8970.28
   0003       15377.45
   0004         349.03
   0005        3498.44
   ....         ...
  </code></pre>
  
  <p>So I do a join like this:</p>
  
  <pre><code>Select t1.SalesId, t2.AvgMnthSales
  from table1 t1
  left join
  table2 t2
  on t1.SalesId = t2.SalesId
  </code></pre>
  
  <p>and get something like this:</p>
  
  <pre><code>   SalesId      AvgMnthSales
       0001        22253.34
       0004          349.03
       0345         NULL
       1009         NULL
       2290         8846.56
       ....          ....
  </code></pre>
  
  <p>What I'd prefer is to have any <code>NULL</code> converted to <code>0</code>.  I've seen some examples where this was done in a two step process of sending the results to a temp table and then converting <code>NULL</code>'s to <code>0</code>'s, but was curious if there's a single step way to do this.  </p>
  
  <p>The reason is largely due to ignorance.  I'm not sure how temp tables are handled (in <code>RAM</code> or on disk) and how much space they take up as this is a large data set and it would likely take up several <code>GB</code>'s of <code>RAM</code> or disk space.</p>
  
  <p>Any suggestions would be appreciated.</p>