CAST and CONVERT

Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.

Syntax

Using CAST:

CAST <strong>( </strong><em>expression</em><strong> </strong>AS <em>data_type </em><strong>) </strong>

Using CONVERT:

CONVERT <strong>( </strong><em>data_type </em>[ <strong>( </strong><em>length </em><strong>) </strong>] <strong>,</strong> <em>expression</em> [ <strong>,</strong> <em>style </em>] <strong>)</strong>

<strong>
<div style="text-align: center"><img alt="SqlCAST.gif" id="image223" src="http://www.galhano.com/blog/wp-content/2006/12/SqlCAST.gif" /></div>
</strong>

Comments are closed.