我在這個SQL查詢錯誤SQL查詢,同時分割字符串
Declare @str Varchar(100) = 'asasa,bsasas,csasa,dsczxvvc'
declare @d varchar(2)=','
SELECT
RIGHT(LEFT(@str,Number-1),
CHARINDEX(@d,REVERSE(LEFT(@[email protected],Number-1))))
FROM
master..spt_values
WHERE
Type = 'P' AND Number BETWEEN 1 AND LEN(@str)
AND SUBSTRING(@str,Number,1) = @d
預期結果
(No column name)
asasa
bsasas
csasa
dsczxvvc
實際結果
(No column name)
asasa
bsasas
csasa