{"id":237,"date":"2007-01-09T13:58:12","date_gmt":"2007-01-09T12:58:12","guid":{"rendered":"http:\/\/www.galhano.com\/blog\/?p=237"},"modified":"2008-02-07T18:24:09","modified_gmt":"2008-02-07T17:24:09","slug":"cast-and-convert-transact-sql","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=237","title":{"rendered":"CAST and CONVERT (Transact-SQL)"},"content":{"rendered":"<pre id=\"ctl00_LibFrame_ctl04other\" class=\"code\">Syntax for CAST:\r\nCAST ( expression AS data_type [ (length ) ])\r\n\r\nSyntax for CONVERT:\r\nCONVERT ( data_type [ ( length ) ] , expression [ , style ] )<\/pre>\n<pre id=\"ctl00_LibFrame_ctl04other\" class=\"code\"><\/pre>\n<pre id=\"ctl00_LibFrame_ctl04other\" class=\"code\"><\/pre>\n<pre id=\"ctl00_LibFrame_ctl04other\" class=\"code\"><!--more--> DECLARE @myval decimal (5, 2)\r\nSET @myval = 193.57\r\nSELECT CAST(CAST(@myval AS varbinary(20)) AS decimal(10,5))\r\n-- Or, using CONVERT\r\nSELECT CONVERT(decimal(10,5), CONVERT(varbinary(20), @myval))<\/pre>\n<p><!--a548ebb67028cccdbd451f58582a7a87--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Syntax for CAST: CAST ( expression AS data_type [ (length ) ]) Syntax for CONVERT: CONVERT ( data_type [ ( length ) ] , expression [ , style ] )<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40,9],"tags":[],"class_list":["post-237","post","type-post","status-publish","format-standard","hentry","category-sql","category-sql-server","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/237","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=237"}],"version-history":[{"count":0,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/237\/revisions"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}