1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| DECLARE @Sample TABLE
(
Data VARCHAR(50)
)
INSERT @Sample select REF_UTIL from DEP_ETAT_BRD_PRIX_TMP655
SELECT *
,
CASE
WHEN LEN(PARSENAME('.' + Data, 3)) is null
THEN LEN(PARSENAME('.' + Data,2))
ELSE
LEN(PARSENAME('.' + Data, 3))
END --AS part
,
LEN(PARSENAME('.' + Data, 3)) as A ,
PARSENAME('.' + Data, 3) as B,
LEN(PARSENAME('.' + Data, 2)) as C,
PARSENAME('.' + Data, 2) as D,
LEN(PARSENAME('.' + Data, 1)) as E,
PARSENAME('.' + Data, 1) as F
FROM @Sample
ORDER BY
CASE
WHEN PARSENAME('.' + Data, 3)is null
THEN PARSENAME('.' + Data,2)
ELSE
PARSENAME('.' + Data, 3)
END --AS part
,
CASE
WHEN LEN(PARSENAME('.' + Data, 3)) is null
THEN LEN(PARSENAME('.' + Data,2))
ELSE
LEN(PARSENAME('.' + Data, 3))
END --AS part
,
PARSENAME('.' + Data, 3),
LEN(PARSENAME('.' + Data, 2)),
PARSENAME('.' + Data, 2),
LEN(PARSENAME('.' + Data, 1)),
PARSENAME('.' + Data, 1) |
Partager