title: Converting int value to a char that is too small
body: <p>Try the following on MSSQL 2005:</p>
  
  <pre><code>select convert(char(2), 123)
  </code></pre>
  
  <p>The key here is that char(2) is too small to accept the value '123'. I would expect to see a truncation error here, but instead the value "*" is returned.</p>
  
  <p><strong>Update:</strong>
  A few of the answers showed how to cast in a way that will cause an error. That's not really what I need. We have lots of code that uses a specific field that used to be declared char(2) but has since been changed to int. My goal here is to make sure that code that hasn't been converted will fall over if it encounters data that it can't handle. So we can go fix it.</p>
  
  <p>Interestingly, <a href="https://stackoverflow.com/questions/3149740/converting-int-value-to-a-char-that-is-too-small/3149808#3149808">dsolimano</a> notes that changing the above type to nchar causes the expected error, and <a href="https://stackoverflow.com/questions/3149740/converting-int-value-to-a-char-that-is-too-small/3149782#3149782">Justin Niessner</a> notes that both of these are by design. Strange inconsistency given that nchar is for Unicode support, hey?</p>
  
  <p>From the answers I have here, it appears that I sadly can't make the server throw the error for existing code. </p>