title: Copy null data to not null in a column
body: <p>I want to copy the data in some old columns to some newly created columns, in the same table. Some columns are <code>bit</code> and some are <code>text</code> (old) to <code>varchar</code> (new). The difficulty I'm running into is that the old columns have some null data in them, whereas the new columns are <code>not null</code>. How can I make it so that if the old data is null, then the new data gets a not null value, either 0 or '', depending.</p>
  
  <pre><code>BEGIN TRY
      BEGIN TRANSACTION
  
      update tblProject
          set
              NewBitColumn1 = OldBitColumn1,
              NewBitColumn2 = OldBitColumn2,
              NewBitColumn3 = OldBitColumn3,
  
              NewVarCharColumn1 = OldTextColumn1,
              NewVarCharColumn2 = OldTextColumn2,
              NewVarCharColumn3 = OldTextColumn3,
  
          COMMIT TRAN -- Transaction Success
      END TRY
  BEGIN CATCH
  
          DECLARE @ErrorMessage NVARCHAR(4000) = ERROR_MESSAGE()
          DECLARE @ErrorSeverity INT = ERROR_SEVERITY()
          DECLARE @ErrorState INT = ERROR_STATE()
  
      IF @@TRANCOUNT &gt; 0
          ROLLBACK TRAN --RollBack in case of Error
  
      RAISERROR(@ErrorMessage, @ErrorSeverity, @ErrorState)
  END CATCH
  </code></pre>