I'm trying to parse a field whereas at any second occurrance of a character value(') start from there and drop them into another field separately by ('). The below query works but keeps ASC the values
exp.
tr'1245'lt'ba'max'74
tr'1845'lkt'bf1a'7max'749
It needs to start at the second (') and put the remaining values in separate fields separated by (')
I tried this but it keeps puting the characters after the second(') in ascending order.
SELECT keyid, [1] as Mod1,[2] as Mod2,[3]as Mod3,[4] as Mod4
FROM (SELECT keyid, keytypes,
ROW_NUMBER() OVER(
PARTITION BY keyid ORDER BY keyid ) AS rownum
FROM (SELECT keyid, keytypes
FROM tablekeys ) AS D1) AS D2
PIVOT(MAX(keytypes)
FOR rownum IN([1],[2],[3],[4])) AS P
exp.
tr'1245'lt'ba'max'74
tr'1845'lkt'bf1a'7max'749
It needs to start at the second (') and put the remaining values in separate fields separated by (')
I tried this but it keeps puting the characters after the second(') in ascending order.
SELECT keyid, [1] as Mod1,[2] as Mod2,[3]as Mod3,[4] as Mod4
FROM (SELECT keyid, keytypes,
ROW_NUMBER() OVER(
PARTITION BY keyid ORDER BY keyid ) AS rownum
FROM (SELECT keyid, keytypes
FROM tablekeys ) AS D1) AS D2
PIVOT(MAX(keytypes)
FOR rownum IN([1],[2],[3],[4])) AS P