title: Implicit casting when joining fields of different types
body: <p>I am joining a field that has single digit numbers formatted with a leading 0 to another that does not have leading 0's.  When I realized this I tested my query out only to find that it was actually working perfectly.  Then I realized what I'd done... I had joined an nvarchar field to an int field.  I would have thought sql would have given me an error for this but apparently it converts the character field to an int field for me.</p>
  
  <p>I realize this is probably not a good practice and I plan to explicitly cast it myself now, but I'm just curious if there are rules for how SQL decides which field to cast in these situations.  What's to keep it from casting the int field to a character type instead (in which case my query would no longer work properly)?</p>