{"id":1403,"date":"2021-07-26T13:44:20","date_gmt":"2021-07-26T12:44:20","guid":{"rendered":"https:\/\/coding.moris.org\/?p=1403"},"modified":"2021-07-26T13:44:20","modified_gmt":"2021-07-26T12:44:20","slug":"convert-a-value-from-scientific-notation-to-decimal-in-t-sql","status":"publish","type":"post","link":"https:\/\/priscimon.net\/coding\/2021\/07\/26\/convert-a-value-from-scientific-notation-to-decimal-in-t-sql\/","title":{"rendered":"Convert a value from scientific notation to decimal in T-SQL"},"content":{"rendered":"\n<p>A <code>VARCHAR<\/code> value that is in scientific notation can be converted to a <code>DECIMAL<\/code> value by first converting it to a <code>REAL<\/code> value, then to the <code>DECIMAL<\/code> value.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE @s VARCHAR(10) = '9.0E-4';\nSELECT CONVERT(DECIMAL(8, 4), CONVERT(REAL, @s));<\/code><\/pre>\n\n\n\n<p>This also works with <code>CAST<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A VARCHAR value that is in scientific notation can be converted to a DECIMAL value by first converting it to a REAL value, then to the DECIMAL value. For example: This also works with CAST.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1403","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3I4g9-mD","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/1403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/comments?post=1403"}],"version-history":[{"count":3,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/1403\/revisions"}],"predecessor-version":[{"id":1406,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/1403\/revisions\/1406"}],"wp:attachment":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/media?parent=1403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/categories?post=1403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/tags?post=1403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}