Nepethya Rana

Nepethya Rana

  • NA
  • 335
  • 152.8k

Query to get data which has html tag from db Table

Oct 18 2017 3:05 PM
I do have table which has data as in html tags.
 
I need to export these data to excel file as for report.
 
But since one of the columns has data as html tags, Image tags etc, How do i get plain text out of it?
 
For example :
If a row has data :

Truck 1

1497 pc


 

Projected time out on Day 3 will be around 4pm

 
 
I want as data in my excel as
 
Truck 1
1497 pc
Projected time out on Day 3 will be around 4pm
 
 if only it is possible other wise seperate is

and
tag with comma.

 
and if data is image link ,
I just want the link in my excel .
 
 
This is my current function that returns with html tags
 
ALTER FUNCTION [dbo].[ufnGetProjectNotes](@ProjectID int)
RETURNS nvarchar(max)
AS
BEGIN
DECLARE @projectNotes nvarchar(max);
SELECT @projectNotes =stuff( (SELECT ','+Notes
FROM [StoreDevelopment].[dbo].[ProjectNotes] p2
WHERE p2.ProjectID = p1.ProjectID
FOR XML PATH(''), TYPE).value('.', 'nvarchar(max)')
,1,1,'')
FROM [StoreDevelopment].[dbo].[ProjectNotes] p1
GROUP BY ProjectID having projectid=@ProjectID;

RETURN @projectNotes;
END
 
 
How do i write the query ?
 
 
 

Answers (1)