{"id":146965,"date":"2015-03-31T16:15:19","date_gmt":"2015-03-31T21:15:19","guid":{"rendered":"https:\/\/mkncreations.com\/site\/?p=146965"},"modified":"2015-03-31T16:15:19","modified_gmt":"2015-03-31T21:15:19","slug":"tsql-extract-numbers-from-string","status":"publish","type":"post","link":"https:\/\/mkncreations.com\/site\/2015\/03\/tsql-extract-numbers-from-string\/","title":{"rendered":"TSQL &#8211; Extract Numbers from String"},"content":{"rendered":"<p>If you want to extract numbers all the numbers (8702000118) from the following string &#8220;BlaBla Hill is &#8211; 870-200-0118 abx&#8221; just use the code below:<\/p>\n<blockquote><p>\nDECLARE @YourString VARCHAR(256);<br \/>\nSET @YourString =&#8217;BlaBla Hill is &#8211; 870-200-0118 abx&#8217;<\/p>\n<p>DECLARE @intAlpha INT<br \/>\nSET @intAlpha = PATINDEX(&#8216;%[^0-9]%&#8217;, @YourString)<br \/>\nBEGIN<br \/>\nWHILE @intAlpha > 0<br \/>\nBEGIN<br \/>\nSET @YourString = STUFF(@YourString, @intAlpha, 1, &#8221; )<br \/>\nSET @intAlpha = PATINDEX(&#8216;%[^0-9]%&#8217;, @YourString )<br \/>\nEND<br \/>\nEND<br \/>\nSELECT ISNULL(@YourString,0)\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>If you want to extract numbers all the numbers (8702000118) from the following string &#8220;BlaBla Hill is &#8211; 870-200-0118 abx&#8221; just use the code below:&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,12],"tags":[155,79,21,154,50,78,156,49],"class_list":["post-146965","post","type-post","status-publish","format-standard","hentry","category-how_to","category-sql","tag-extract","tag-microsoft","tag-ms","tag-number","tag-sql-2","tag-sql2008","tag-string","tag-tsql"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/146965"}],"collection":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/comments?post=146965"}],"version-history":[{"count":1,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/146965\/revisions"}],"predecessor-version":[{"id":147076,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/146965\/revisions\/147076"}],"wp:attachment":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/media?parent=146965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/categories?post=146965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/tags?post=146965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}