{"id":224,"date":"2006-12-27T12:19:00","date_gmt":"2006-12-27T11:19:00","guid":{"rendered":"http:\/\/www.galhano.com\/blog\/?p=224"},"modified":"2006-12-27T12:19:00","modified_gmt":"2006-12-27T11:19:00","slug":"cast-and-convert","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=224","title":{"rendered":"CAST and CONVERT"},"content":{"rendered":"<p>Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.<\/p>\n<h5>Syntax<\/h5>\n<p class=\"label\"><strong>Using CAST:<\/strong><\/p>\n<p><code>CAST &lt;strong&gt;( &lt;\/strong&gt;&lt;em&gt;expression&lt;\/em&gt;&lt;strong&gt; &lt;\/strong&gt;AS &lt;em&gt;data_type &lt;\/em&gt;&lt;strong&gt;) &lt;\/strong&gt;<\/code><\/p>\n<p class=\"label\"><strong>Using CONVERT:<\/strong><\/p>\n<p><code>CONVERT &lt;strong&gt;( &lt;\/strong&gt;&lt;em&gt;data_type &lt;\/em&gt;[ &lt;strong&gt;( &lt;\/strong&gt;&lt;em&gt;length &lt;\/em&gt;&lt;strong&gt;) &lt;\/strong&gt;] &lt;strong&gt;,&lt;\/strong&gt; &lt;em&gt;expression&lt;\/em&gt; [ &lt;strong&gt;,&lt;\/strong&gt; &lt;em&gt;style &lt;\/em&gt;] &lt;strong&gt;)&lt;\/strong&gt;<\/code><\/p>\n<p><code>&lt;strong&gt;<br \/>\n&lt;div style=&quot;text-align: center&quot;&gt;&lt;img alt=&quot;SqlCAST.gif&quot; id=&quot;image223&quot; src=&quot;http:\/\/www.galhano.com\/blog\/wp-content\/2006\/12\/SqlCAST.gif&quot; \/&gt;&lt;\/div&gt;<br \/>\n&lt;\/strong&gt;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality. Syntax Using CAST: CAST &lt;strong&gt;( &lt;\/strong&gt;&lt;em&gt;expression&lt;\/em&gt;&lt;strong&gt; &lt;\/strong&gt;AS &lt;em&gt;data_type &lt;\/em&gt;&lt;strong&gt;) &lt;\/strong&gt; Using CONVERT: CONVERT &lt;strong&gt;( &lt;\/strong&gt;&lt;em&gt;data_type &lt;\/em&gt;[ &lt;strong&gt;( &lt;\/strong&gt;&lt;em&gt;length &lt;\/em&gt;&lt;strong&gt;) &lt;\/strong&gt;] &lt;strong&gt;,&lt;\/strong&gt; &lt;em&gt;expression&lt;\/em&gt; [ &lt;strong&gt;,&lt;\/strong&gt; &lt;em&gt;style &lt;\/em&gt;] &lt;strong&gt;)&lt;\/strong&gt; &lt;strong&gt; &lt;div style=&quot;text-align: center&quot;&gt;&lt;img alt=&quot;SqlCAST.gif&quot; id=&quot;image223&quot; src=&quot;http:\/\/www.galhano.com\/blog\/wp-content\/2006\/12\/SqlCAST.gif&quot; \/&gt;&lt;\/div&gt; &lt;\/strong&gt;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-224","post","type-post","status-publish","format-standard","hentry","category-sql-server","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=224"}],"version-history":[{"count":0,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/224\/revisions"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=224"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}