title: How to rollback a transaction in TSQL when string data is truncated?
body: <p>Currently I have a large import process that I'm trying to wrap inside a transaction so if anything breaks - i could rollback.  The issue I have is that when the TSQL inside the trans blows up, it won't rollback when the following SQL error occurs</p>
  
  <pre><code>Msg 8152, Level 16, State 14, Line 249
  String or binary data would be truncated.
  The statement has been terminated.
  </code></pre>
  
  <p>The below wraps this import TSQL</p>
  
  <pre><code>DECLARE @error INT
  SELECT @error = 0
  BEGIN TRANSACTION
  
  --** begin import TSQL
  
  --** end import TSQL
  
  SELECT @error = @@error 
  IF @error != 0 GOTO handle_error
  
  COMMIT
  
  handle_error: 
  IF @error != 0 
  BEGIN 
  ROLLBACK 
  END
  </code></pre>