Originally posted by Unknown
You can use the following sub-query to get the text value:
( SELECT [Text]
FROM (
SELECT
TRIM(LEFT(Value,CHARINDEX('^',Value)-1)) AS [Value]
,TRIM(RIGHT(Value,LEN(Value)-CHARINDEX('^',Value))) AS [Text]
FROM string_split((
SELECT AQ.[Value]
FROM Attribute A
INNER JOIN AttributeQualifier AQ ON AQ.AttributeId = A.Id
WHERE A.Id = AV.[AttributeId]
AND AQ.[Key] = 'values'), ',')
) T
WHERE [Value] = AV.[Value] ) AS [TextValue]
If you are using an table alias different than "AV" for your Attribute Value table, you'll need to change that in the two places it appears in the sub query (AV.[AttributeId] and AV.[Value])
