Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

MS-SQL - Best Way To Split Data

$
0
0

I have data in a field that I need to split into separate fields. Fortunately the data is comma separated. The data looks like the following:

SQL
$206.00,$196.00,10/25/2016

I need the data split into three fields. I'm currently doing the following, which seems to work:
SQL
right(left(r.text,charindex(',',r.text)-2),len(left(r.text,charindex(',',r.text)-2))-1)amount,right(left(substring(r.text,charindex(',',r.text)+3,len(r.text)),charindex(',',substring(r.text,charindex(',',r.text)+3,len(r.text)))-2),len(left(substring(r.text,charindex(',',r.text)+3,len(r.text)),charindex(',',substring(r.text,charindex(',',r.text)+3,len(r.text)))-2)))amount_w_reduction,convert(varchar(8),convert(date,left(right(r.text,charindex(',',r.text)+1),len(right(r.text,charindex(',',r.text)+1))),101),1)enddue_date

However, I'm...

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>