{"id":1506,"date":"2013-01-09T13:00:03","date_gmt":"2013-01-09T13:00:03","guid":{"rendered":"http:\/\/galhano.com\/blog\/?p=1506"},"modified":"2013-01-09T13:01:08","modified_gmt":"2013-01-09T13:01:08","slug":"get-a-substring-in-sql-server-using-space-as-separator","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=1506","title":{"rendered":"get a substring in SQL SERVER using space as separator"},"content":{"rendered":"<p>get a substring in SQL SERVER using space as separator<\/p>\n<p>[sql]<\/p>\n<p>SELECT CASE CHARINDEX(&#8216; &#8216;, news.description, 40)<br \/>\n  WHEN 0 THEN news.description<br \/>\n  ELSE SUBSTRING(news.description, 0, CHARINDEX(&#8216; &#8216;, news.description, 40) &#8211; 0)<br \/>\n  END<br \/>\n AS FirstWord<br \/>\nFROM news<br \/>\n[\/sql]<\/p>\n<p>source:<br \/>\nhttp:\/\/www.dreamincode.net\/forums\/topic\/239440-how-can-i-get-a-substring-in-sql-server-using-space-as-separator\/<br \/>\nCHARINDEX (Transact-SQL) http:\/\/msdn.microsoft.com\/pt-pt\/library\/ms186323.aspx<\/p>\n<p>SUBSTRING (Transact-SQL)http:\/\/msdn.microsoft.com\/en-us\/library\/ms187748.aspx<\/p>\n","protected":false},"excerpt":{"rendered":"<p>get a substring in SQL SERVER using space as separator [sql] SELECT CASE CHARINDEX(&#8216; &#8216;, news.description, 40) WHEN 0 THEN news.description ELSE SUBSTRING(news.description, 0, CHARINDEX(&#8216; &#8216;, news.description, 40) &#8211; 0) END AS FirstWord FROM news [\/sql] source: http:\/\/www.dreamincode.net\/forums\/topic\/239440-how-can-i-get-a-substring-in-sql-server-using-space-as-separator\/ CHARINDEX (Transact-SQL) http:\/\/msdn.microsoft.com\/pt-pt\/library\/ms186323.aspx SUBSTRING (Transact-SQL)http:\/\/msdn.microsoft.com\/en-us\/library\/ms187748.aspx<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,104],"tags":[],"class_list":["post-1506","post","type-post","status-publish","format-standard","hentry","category-sql-server","category-transact-sql","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1506"}],"version-history":[{"count":3,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1506\/revisions"}],"predecessor-version":[{"id":1509,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1506\/revisions\/1509"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1506"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}