How to Split String by Character into Separate Columns in SQL Server

前端 未结 5 1219
清歌不尽
清歌不尽 2020-12-03 19:17

I have one field in SQL Server containing section, township and range information, each separated by dashes; for example: 18-84-7. I\'d like to have this infor

5条回答
  •  时光取名叫无心
    2020-12-03 19:20

    Its better to replace the second section answered by BWS by this one :

    select SUBSTRING(dat,CHARINDEX('-', dat) + 1,LEN(dat) - CHARINDEX('-', dat) - CHARINDEX('-', REVERSE(dat)) ) from myTable.
    

提交回复
热议问题