title: Check if field is null or empty and insert sql server 2008
body: <p>Bit rusty in sql</p>
  
  <p>I have a situation where I need to  insert a field "@Amount" into a temp table.If @amount from tableA is null or 0 get it from tableB</p>
  
  <p>This is a simplified example of what I am doing.This must be done within a select statement when inserting into #CustomerTable
  Do I need a case when statement?</p>
  
  <pre><code>DECLARE @Amount DECIMAL(18,4) 
  
  SELECT @Amount=Amount
  FROM TableA
  
  INSERT #CustomerTable(id,Name,Amount)
  SELECT 1,CustomerName,--if Amount is null or 0 get it from TableB else Get it from Table A.
  FROM TableB
  </code></pre>