This is my store to process get data:
(PromotionSetup.query(''
for $PS in Setup/Include[@Type = ''''Product'''']/Value[text()]
where contains($PS, ''''' + CAST(@productID AS NVARCHAR) + '_'''') or $PS = ''''' + CAST(@productID AS NVARCHAR) + '''''
return data($PS)
'')).value(''(.)'', ''nvarchar(max)'') as InfoProductPromotion
And, this is my result:
468908_3:2000; 468908_3:1000;
That result was compare 2 data in one line. So, i'm looking in the internet that using cross apply
to detached data in 2 lines.
This is a result i want:
468908_3:2000;
468908_3:1000;
Unfortunately, i can't imagine how to using cross apply into Xquery. Can someone can help me??
Check this sql statement if it can help :
;WITH yourtable
AS (SELECT '468908_3:2000; 468908_3:1000;' AS yourcolumn)
SELECT RTRIM(LTRIM(c1.value('.', 'varchar(100)')))
FROM (SELECT CAST('<N>' + REPLACE(yourcolumn, ';', ';</N><N>')
+ '</N>' AS XML)
FROM yourtable) t(c)
CROSS APPLY c.nodes('/N') AS t1(c1)
WHERE RTRIM(LTRIM(c1.value('.', 'varchar(100)'))) <> ''
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.