{"id":585,"date":"2007-09-12T16:48:48","date_gmt":"2007-09-12T07:48:48","guid":{"rendered":"http:\/\/www.hits-net.com\/blog\/?p=585"},"modified":"2007-09-12T16:48:48","modified_gmt":"2007-09-12T07:48:48","slug":"transact-sql%e3%81%ab%e5%bc%95%e3%81%a3%e3%81%8b%e3%81%8b%e3%82%8b%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.hits-net.com\/blog\/?p=585","title":{"rendered":"Transact-SQL\u306b\u5f15\u3063\u304b\u304b\u308b\u3002"},"content":{"rendered":"<p>\u3044\u3084\u3041\u3069\u3082\u3002<\/p>\n<p>\u304a\u4e45\u3057\u3076\u308a\u3067\u3059\u3002<\/p>\n<p>\u304a\u4e45\u3057\u3076\u308a\u3067\u3059\u304c\u3001\u500b\u4eba\u30e1\u30e2\u3002<\/p>\n<p>Transac-SQL\u3067\u6587\u5b57\u304b\u3089\u6570\u5b57\u3078\u5909\u63db<br \/>\u30c6\u30fc\u30d6\u30eb Test<br \/>data(nvarchar)<br \/>&#8212;&#8212;&#8212;-<br \/>01<br \/>\u3000010<br \/>0003<br \/>A<br \/>\u3000B<br \/>&#8212;&#8212;&#8212;-<\/p>\n<p>\u2191\u306e\u3088\u3046\u306a\u3081\u3061\u3083\u304f\u3061\u3083\u306a\u30c7\u30fc\u30bf\u306e\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u304d\u308c\u3044\u306b\u5024\u3092\u53d6\u308a\u3060\u3059\u3002<\/p>\n<p>\u76ee\u6307\u3059\u7d50\u679c\u306f<br \/>Result<br \/>&#8212;&#8212;&#8211;<br \/>1<br \/>10<br \/>A<br \/>B<\/p>\n<p>\u3053\u306e\u5834\u5408\u3001\u6570\u5b57\u3092\u4e00\u5ea6integer\u3067CAST\u3059\u308b\u3053\u3068\u3067\u3001\u982d\u306e\u7a7a\u767d\u30840\u3092\u306f\u305a\u305b\u307e\u3059\u3001\u304c\u3001Cast\u3060\u3068A\u3068B\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3053\u3093\u306a\u98a8\u306b\u3002<br \/>select<br \/>  case when (IsNumeric(data)) = 1 then Cast(data as Integer)<br \/>       else Ltrim(Rtrim(data))<br \/>  end as Result<br \/>From Test<\/p>\n<p>\u304a\u3063\u3068\uff01\u305f\u3060\u3057\u30b3\u30ec\u3058\u3083\u300cnvarchar\u3092int\u306b\u5909\u63db\u3067\u304d\u307e\u305b\u3093\u300d\u7684\u306a\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u6b63\u76f4\u4e00\u6669\u60a9\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u306a\u305c\u304b\u3002<\/p>\n<p>\u307e\u305a\u3053\u306eSQL\u306f\u7279\u306b\u30bd\u30fc\u30c8\u3057\u3066\u3044\u307e\u305b\u3093\u306e\u3067\u30c6\u30fc\u30d6\u30eb\u306e\u4e0a\u304b\u3089\u51e6\u7406\u3057\u307e\u3059\u3002<\/p>\n<p>01\u306fisnumeric\u30671\u304c\u5e30\u3063\u3066\u304d\u307e\u3059\u3002\u305d\u3053\u3067Cast\u3059\u308b\u3093\u3067\u3059\u304c\u3001\u3053\u306e\u3068\u304d\u306b\u30a8\u30a4\u30ea\u30a2\u30b9\u300cResult\u300d\u306e\u578b\u304cinteger\u306b\u6c7a\u5b9a\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u3093\u3060\u3002\u3053\u307e\u3063\u305f\u3060\u3002<\/p>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u3002<\/p>\n<p>select<br \/>  case when (IsNumeric(data)) = 1 then str(Cast(data as Integer))<br \/>       else Ltrim(Rtrim(data))<br \/>  end as Result<br \/>From Test<\/p>\n<p>\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u3066\u3084\u308a\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u3041\u3061\u3087\u3063\u3068\u7279\u6b8a\u306a\u4e8b\u4f8b\u3067\u3059\u304c\u3001\u8ab0\u304b\u56f0\u3063\u305f\u4eba\u306e\u53c2\u8003\u306b\u3067\u3082\u306a\u308c\u3070\u3046\u308c\u3057\u3044\u3067\u3059\u3002<\/p>\n<p>\u3042\u3041\u307e\u3060\u307e\u3060\u4fee\u884c\u304c\u305f\u308a\u3093\u306a\u3041\u3002\u3002\u3002<\/p>\n<p>\u691c\u7d22\uff1a<br \/>Transact-SQL Cast IsNumeric Case When nvarchar\u306e\u5024 \u3092\u30c7\u30fc\u30bf\u578b int \u306b\u5909\u63db\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f \u30e1\u30c3\u30bb\u30fc\u30b8 245 \u30ec\u30d9\u30eb 16<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3044\u3084\u3041\u3069\u3082\u3002 \u304a\u4e45\u3057\u3076\u308a\u3067\u3059\u3002 \u304a\u4e45\u3057\u3076\u308a\u3067\u3059\u304c\u3001\u500b\u4eba\u30e1\u30e2\u3002 Transac-SQL\u3067\u6587\u5b57\u304b\u3089\u6570\u5b57\u3078\u5909\u63db\u30c6\u30fc\u30d6\u30eb Testdata(nvarchar)&#8212;&#8212;&#8212;-01\u30000100003A\u3000B &hellip; <a href=\"https:\/\/www.hits-net.com\/blog\/?p=585\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">Transact-SQL\u306b\u5f15\u3063\u304b\u304b\u308b\u3002<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[30],"tags":[],"class_list":["post-585","post","type-post","status-publish","format-standard","hentry","category-30"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p4WH5i-9r","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.hits-net.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hits-net.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hits-net.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hits-net.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hits-net.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=585"}],"version-history":[{"count":0,"href":"https:\/\/www.hits-net.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/585\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hits-net.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hits-net.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hits-net.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}