Last post Jan 26, 2015 03:19 PM by JoyceW
Jan 26, 2015 02:41 PM|simflex|LINK
Hello, again experts.
When I run the following query:
select orderId, comments from Orders where orderId=201
The result is displayed in one or more rows depending on the length of the text.
If the text is more than 250, the comments are split into two rows.
201 This line is more than 250 characters. Therefore,
201 rest goes to.
Problem with this is that when I attempt to display the comments on my app, on the portion on row one gets displayed. The rest are ignored.
How do I modify the query above so that entire comment is displayed to the user?
Thanks in advance as always.
Jan 26, 2015 02:59 PM|gimimex|LINK
STUFF( (SELECT ' ' + s.comments
FROM Orders as s
WHERE s.orderId = o.orderId
FOR XML PATH(''), TYPE).value('.', 'varchar(max)')
,1, 1, '') as comments
FROM Orders as o
o.orderId = 201
Hope this helps.
Jan 26, 2015 03:18 PM|simflex|LINK
THANK YOU, THANK YOU, gimimex
Jan 26, 2015 03:19 PM|JoyceW|LINK
You can also try:
select orderID, replace(replace(comments,'<comments>',' '), '</comments>','')
from(select orderid ,(select comments from Orders where orderid = a.orderid for xml path('') ) as [Comments] from Orders a) t1