Microsoft T-SQL: Can I CONVERT smallint to varchar
<p>It may just be me, but... Despite the fact that most sql developers may consider cast &amp; convert to be very basic stuff, and that may be true, I find Microsoft's documentation page on CAST &amp; CONVERT to be one of the most hideous, not-intuitively-laid-out, hard to understand things I have ever seen. Much of their documentation is great. Like constantly trying to blend the entire page into a mix of both cast and convert, jumping back and forth in each sentence... rather than dealing with them separately. And who puts the target_type as the first argument? Putting the expression as the first argument would be more intuitive - and follow the other 99% of numerous programming languages' syntax.  UH</p>

<p>MS says that I can only convert to 3 data types: (well actually I'm not really sure if this applies to both CAST and CONVERT, since they ARE, in fact, different... But according to the layout of that webpage, it apparently applies equally to both - even though I already know for a fact that it is not true for CAST, which I use much more frequently).  </p>

<p>It says:  "Is the target data type. This includes xml, bigint, and sql_variant"  </p>

<p>Putting aside for the moment the fact that I CAST things as many other datatypes all the time (date, varchar), </p>

<p>My immediate question is:  if I can only CONVERT to those data types, then why does this work?</p>

<pre><code>select CONVERT(varchar(200), cast(50 as smallint))
</code></pre>

<p>And finally, I'd like to run an <code>INSERT</code> that will be getting a <code>smallint</code> and putting it into a <code>varchar(200)</code> column.  </p>

<p>All I'm trying to do is avoid any failures, so maybe I don't really "need" to convert or cast over to <code>varchar</code>, but any commments on</p>

<ol>
<li>answer on what is my apparent misunderstanding about the <code>CONVERT</code> documentation</li>
</ol>

<p>or</p>

<ol start="2">
<li>how to safely convert it to insert to <code>varchar</code></li>
</ol>

<p>are welcome. As long as you're not just overly unpleasant, since there are always those MS fans who get hot under the collar at all critiques of MS .. :|</p>