{"id":146808,"date":"2015-03-31T10:52:28","date_gmt":"2015-03-31T15:52:28","guid":{"rendered":"https:\/\/mkncreations.com\/site\/?p=146808"},"modified":"2015-03-31T10:55:41","modified_gmt":"2015-03-31T15:55:41","slug":"tsql-format-phone-numbers","status":"publish","type":"post","link":"https:\/\/mkncreations.com\/site\/2015\/03\/tsql-format-phone-numbers\/","title":{"rendered":"TSQL &#8211; Format Phone Numbers"},"content":{"rendered":"<p>This will teach you how to format a phone number from 1234567890 to (123) 456-7890. <\/p>\n<p><strong>SQL Server 2008:<\/strong><\/p>\n<blockquote><p>\nSELECT [Phone] AS [Phone Number]<br \/>\n, &#8216;(&#8216;+(SUBSTRING(Phone,1,3)+&#8217;) &#8216;+SUBSTRING(Phone,4,3) +&#8217;-&#8216; +SUBSTRING(Phone,7,4)) AS [Formatted Phone Number]<br \/>\nFROM (SELECT &#8216;1234567890&#8217; AS [Phone]) as x\n<\/p><\/blockquote>\n<p><strong>SQL Server 2012 and above:<\/strong><\/p>\n<blockquote><p>\nSELECT<br \/>\n [Phone Numbers]<br \/>\n,FORMAT([Phone Numbers],'(###) ###-####&#8217;) AS [Formatted Phone Number]<br \/>\nFROM (SELECT &#8216;1234567890&#8217; AS [Phone Numbers]) as x\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>This will teach you how to format a phone number from 1234567890 to (123) 456-7890. SQL Server 2008: SELECT [Phone] AS [Phone Number] , &#8216;(&#8216;+(SUBSTRING(Phone,1,3)+&#8217;)&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":[45,79,21,154,153,152,50,78,151,49],"class_list":["post-146808","post","type-post","status-publish","format-standard","hentry","category-how_to","category-sql","tag-format","tag-microsoft","tag-ms","tag-number","tag-phone","tag-phonenumber","tag-sql-2","tag-sql2008","tag-sql2012","tag-tsql"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/146808"}],"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=146808"}],"version-history":[{"count":5,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/146808\/revisions"}],"predecessor-version":[{"id":146826,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/146808\/revisions\/146826"}],"wp:attachment":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/media?parent=146808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/categories?post=146808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/tags?post=146808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}