{"id":84,"date":"2023-02-24T09:40:12","date_gmt":"2023-02-24T01:40:12","guid":{"rendered":"https:\/\/jeffrey.gsgoldprice.com\/?p=84"},"modified":"2023-02-24T09:40:26","modified_gmt":"2023-02-24T01:40:26","slug":"how-to-get-the-1st-value-before-delimiter-in-sql-server","status":"publish","type":"post","link":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/2023\/02\/24\/how-to-get-the-1st-value-before-delimiter-in-sql-server\/","title":{"rendered":"<a href=\"https:\/\/stackoverflow.com\/questions\/19547031\/how-to-get-the-1st-value-before-delimiter-in-sql-server\">How to get the 1st value before delimiter in sql server<\/a>"},"content":{"rendered":"\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">\uff31uestion\uff1a<\/mark><\/strong><\/p>\n\n\n\n<p>In one of the column i am getting 2 values with a delimiter between it How to extract both the values<\/p>\n\n\n\n<p>I have some thing like this Column&nbsp;<code>TRN02<\/code>&nbsp;is&nbsp;<code>115679-5757<\/code><\/p>\n\n\n\n<p>I need to take values before delimiter and after delimter into 2 separate columns again.<\/p>\n\n\n\n<p>Can some one help me on this<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">Answer\uff1a<\/mark><\/strong><a href=\"https:\/\/stackoverflow.com\/posts\/19547129\/timeline\"><\/a><\/p>\n\n\n\n<p>You can use&nbsp;<code>SUBSTRING<\/code>&nbsp;to do this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT \n    SUBSTRING(TRN02, 0, CHARINDEX('-', TRN02)) AS &#91;First]\n    SUBSTRING(TRN02, CHARINDEX('-', TRN02)  + 1, LEN(TRN02)) AS &#91;Second]\nFROM TABLE<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uff31uestion\uff1a In one of the column i am getting 2 values wi&hellip; <a href=\"https:\/\/jeffrey.gsgoldprice.com\/index.php\/2023\/02\/24\/how-to-get-the-1st-value-before-delimiter-in-sql-server\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">&lt;a href=&quot;https:\/\/stackoverflow.com\/questions\/19547031\/how-to-get-the-1st-value-before-delimiter-in-sql-server&quot;&gt;How to get the 1st value before delimiter in sql server&lt;\/a&gt;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-work"],"_links":{"self":[{"href":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":2,"href":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":86,"href":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/wp-json\/wp\/v2\/posts\/84\/revisions\/86"}],"wp:attachment":[{"href":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeffrey.gsgoldprice.com\/index.php\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}