我有一个sql列,它由四个用斜杠(“/”)分隔的连接词组成。单词可以是任意长度的随机单词。如何单独检索每个单词。我需要写什么查询?
由于
答案 0 :(得分:0)
不是“最快的方式”,但它会起作用。
with extract1 as
(
SELECT substring(data, 1, charindex('/', data)-1) AS data1,
substring(data, charindex('/', data)+1, LEN(data)) AS data
from atable
), extract2
(
SELECT data1,substring(data, 1, charindex('/', data)-1) AS data2,
substring(data, charindex('/', data)+1, LEN(data)) AS data
from extract1
)
SELECT data1,data2,substring(data, 1, charindex('/', data)-1) AS data3,
substring(data, charindex('/', data)+1, LEN(data)) AS data4
from extract2