{"id":618,"date":"2014-06-26T14:54:25","date_gmt":"2014-06-26T05:54:25","guid":{"rendered":"http:\/\/astel-labs.net\/blog\/diary\/?p=618"},"modified":"2014-06-26T15:07:23","modified_gmt":"2014-06-26T06:07:23","slug":"26-1-2","status":"publish","type":"post","link":"https:\/\/astel-labs.net\/blog\/diary\/2014\/06\/26-1-2.html","title":{"rendered":"SQL Server \u2013 money\u578b\u3068decimal\u578b\u3092\u4f75\u7528\u3057\u305f\u91d1\u984d\u8a08\u7b97"},"content":{"rendered":"<p>\u81ea\u5206\u7528\u30e1\u30e2\u3067\u3059\u3002<\/p>\n<p>SQL Server \u3092\u5229\u7528\u3057\u3066\u6b63\u78ba\u306a\u91d1\u984d\u8a08\u7b97\u3092\u884c\u3046\u5834\u5408\u3001SQL \u306e\u30c7\u30fc\u30bf\u578b\u306f float \u578b\u3084 real \u578b\u3092\u4f7f\u7528\u3059\u308b\u3068\u5024\u304c\u5207\u308a\u6368\u3066\u3089\u308c\u305f\u308a\u4e38\u3081\u305f\u308a\u3055\u308c\u308b\u305f\u3081\u30010.1\u5186\u5358\u4f4d\u3067\u6b63\u78ba\u306a\u8a08\u7b97\u3092\u884c\u308f\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u7528\u9014\u3067\u306f\u4f7f\u3046\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u91d1\u984d\u8a08\u7b97\u3092\u884c\u3046\u5834\u5408\u3001SQL \u306e\u30c7\u30fc\u30bf\u578b\u306f <a title=\"money \u304a\u3088\u3073 smallmoney (Transact-SQL)\" href=\"http:\/\/msdn.microsoft.com\/ja-jp\/library\/ms179882.aspx\">money(smallmoney)<\/a> \u578b\u307e\u305f\u306f <a title=\"decimal \u578b\u3068 numeric \u578b (Transact-SQL)\" href=\"http:\/\/msdn.microsoft.com\/ja-jp\/library\/ms187746.aspx\">decimal(numeric)<\/a> \u578b\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<br \/>\n\u3067\u3059\u304c\u3001\u91d1\u984d\u3067\u3042\u308b\u3053\u3068\u3092\u660e\u793a\u3059\u308b\u305f\u3081\u3001\u91d1\u984d\u306e\u30c7\u30fc\u30bf\u578b\u306b\u306f money \u578b\u3092\u4f7f\u7528\u3057\u3001\u30d1\u30fc\u30bb\u30f3\u30c8\u306a\u3069\u306e\u5b9a\u6570\u307e\u305f\u306f\u5909\u6570\u306e\u5834\u5408\u306f decimal \u578b\u3092\u4f7f\u7528\u3059\u308b\u306a\u3069\u3001\u4f7f\u3044\u5206\u3051\u308b\u307b\u3046\u304c\u3088\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u307e\u305f\u3001\u91d1\u984d\u8a08\u7b97\u3092\u884c\u3046\u305f\u3081\u306b\u3042\u3089\u304b\u3058\u3081\u77e5\u3063\u3066\u304a\u304b\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u4e88\u5099\u77e5\u8b58\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u3053\u3068\u304c\u6319\u3052\u3089\u308c\u307e\u3059\u3002<br \/>\n\uff11\uff0e<span class=\"input\">money<\/span> \u578b\u3068 <span class=\"input\">smallmoney<\/span> \u578b\u306e\u6709\u52b9\u7bc4\u56f2<br \/>\n<span class=\"input\">money\uff08\uff18\u30d0\u30a4\u30c8\uff09<\/span>\uff1a-922,337,203,685,477.5808 \uff5e 922,337,203,685,477.5807<br \/>\n<span class=\"input\">smallmoney\uff08\uff14\u30d0\u30a4\u30c8\uff09\uff1a<\/span>&#8211; 214,748.3648 \uff5e 214,748.3647<br \/>\n<span class=\"input\">\u203bmoney<\/span> \u30c7\u30fc\u30bf\u578b\u3068 <span class=\"input\">smallmoney<\/span> \u30c7\u30fc\u30bf\u578b\u306f\u3001\u8868\u3057\u3066\u3044\u308b<span style=\"color: #ff0000;\">\u901a\u8ca8\u5358\u4f4d\u306e 10,000 \u5206\u306e 1 \u307e\u3067\u306e\u7cbe\u5ea6<\/span>\u3092\u6301\u3061\u307e\u3059\u3002<\/p>\n<p>\uff12\uff0edecimal \u578b\u306e\u6700\u5927\u6709\u52b9\u6841\u6570\u306f\u3001\u6574\u6570\u90e8\u3068\u5c0f\u6570\u90e8\u306e\u5408\u8a08\u304c38\u6841\u4ee5\u4e0b\u306b\u306a\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n<span style=\"color: #ff0000;\">\u203b\u6709\u52b9\u6841\u6570\u304c38\u6841\u3092\u8d85\u3048\u305f\u5834\u5408\u3001\u6574\u6570\u90e8\u3067\u306e\u5207\u308a\u6368\u3066\u304c\u767a\u751f\u3057\u306a\u3044\u3088\u3046\u306b\u5c0f\u6570\u90e8\u306e\u6709\u52b9\u6841\u6570\u304c\u4e38\u3081\u3089\u308c\u307e\u3059\u3002<\/span><\/p>\n<p>\uff13\uff0edecimal \u578b\u540c\u58eb\u3067\u306e\u8a08\u7b97\u3092\u884c\u3046\u5834\u5408\u3001\u6709\u52b9\u6841\u6570\u304c\u3069\u306e\u3088\u3046\u306b\u5909\u5316\u3059\u308b\u304b\u3092\u77e5\u3063\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u203b<a title=\"NUMERIC\/DECIMAL \u306e\u6f14\u7b97\u7d50\u679c\u306e\u7cbe\u5ea6\u3068\u30b9\u30b1\u30fc\u30eb\u306e\u6c7a\u5b9a\u65b9\u6cd5\" href=\"http:\/\/blogs.msdn.com\/b\/jpsql\/archive\/2013\/05\/08\/numeric-decimal.aspx\"><span style=\"font-family: \u30e1\u30a4\u30ea\u30aa;\">NUMERIC\/DECIMAL \u306e\u6f14\u7b97\u7d50\u679c\u306e\u7cbe\u5ea6\u3068\u30b9\u30b1\u30fc\u30eb\u306e\u6c7a\u5b9a\u65b9\u6cd5<\/span><\/a><\/p>\n<p>\uff14\uff0eTransact-SQL \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3067\u306f\u3001\u5c0f\u6570\u70b9\u306e\u4ed8\u3044\u305f\u5b9a\u6570\u306f\u3001\u5fc5\u8981\u6700\u5c0f\u9650\u306e\u6709\u52b9\u6841\u6570\u3068\u5c0f\u6570\u70b9\u4ee5\u4e0b\u6841\u6570\u3067\u81ea\u52d5\u7684\u306b <span class=\"input\">numeric<\/span> \u578b\u306e\u5024\u306b\u5909\u63db\u3055\u308c\u307e\u3059\u3002<span id=\"mt30\" class=\"sentence\" data-guid=\"f43876a48342acdbaa90ede28e4ecf72\" data-source=\"For example, the constant 12.345 is converted into a &lt;span&gt;&lt;span class=&quot;input&quot;&gt;numeric&lt;\/span&gt;&lt;\/span&gt; value with a precision of 5 and a scale of 3.\">\u305f\u3068\u3048\u3070\u3001\u5b9a\u6570 12.345 \u306f\u6709\u52b9\u6841\u6570\u304c 5\u3001\u5c0f\u6570\u70b9\u4ee5\u4e0b\u6841\u6570\u304c 3 \u306e <span class=\"input\">numeric<\/span> \u578b\u306b\u5909\u63db\u3055\u308c\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0a\u8a18\u3092\u8e0f\u307e\u3048\u3001\u91d1\u984d\u8a08\u7b97\u3092\u884c\u3046\u5834\u5408\u306b\u306f\u5207\u308a\u6368\u3066\u3084\u4e38\u3081\u304c\u3067\u304d\u308b\u9650\u308a\u767a\u751f\u3057\u306a\u3044\u3088\u3046\u3001\u91d1\u984d\u30c7\u30fc\u30bf\u540c\u58eb\u306e\u52a0\u6e1b\u7b97\u3068\u91d1\u984d\u4ee5\u5916\u306e\u5b9a\u6570\u3084\u5909\u6570\u306e\u8a08\u7b97\u306f\u5225\u306b\u8a08\u7b97\u3092\u884c\u3063\u305f\u5f8c\u3001\u6700\u5f8c\u306b\u307e\u3068\u3081\u3066\u8a08\u7b97\u3092\u884c\u3046\u306a\u3069\u306e\u5de5\u592b\u304c\u5fc5\u8981\u306b\u306a\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5206\u7528\u30e1\u30e2\u3067\u3059\u3002 SQL Server \u3092\u5229\u7528\u3057\u3066\u6b63\u78ba\u306a\u91d1\u984d\u8a08\u7b97\u3092\u884c\u3046\u5834\u5408\u3001SQL \u306e\u30c7\u30fc\u30bf\u578b\u306f float \u578b\u3084 real \u578b\u3092\u4f7f\u7528\u3059\u308b\u3068\u5024\u304c\u5207\u308a\u6368\u3066\u3089\u308c\u305f\u308a\u4e38\u3081\u305f\u308a\u3055\u308c\u308b\u305f\u3081\u30010.1\u5186\u5358\u4f4d\u3067\u6b63\u78ba\u306a\u8a08\u7b97\u3092\u884c\u308f\u306a\u3051\u308c\u3070\u306a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-618","post","type-post","status-publish","format-standard","hentry","category-sql-server"],"_links":{"self":[{"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/posts\/618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/comments?post=618"}],"version-history":[{"count":4,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/posts\/618\/revisions"}],"predecessor-version":[{"id":622,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/posts\/618\/revisions\/622"}],"wp:attachment":[{"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/media?parent=618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/categories?post=618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/tags?post=618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}