October 7, 2015 at 8:08 pm
dbishop (10/7/2015)
I know it has been quite some time since this was posted, but I have a question. The code is looking for an EXACT match to the start tag. However, if you have additional info (e.g. <span style=...> or <div class=...> and </span> or </div> you get a parsing error.Is there any way to avoid that? I've found some code that parses character by character but we know that is, like 🙁
I know it's not the answer you wanted but the absolute best way would be to have the app that spawned it to parse it and provide it in a more normal form.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 21, 2016 at 7:46 am
I recently had the same requirement and wrote a function which strips HTML tags and entities regardless of any additional information. I posted the code here at Stack Overflow
I hope it is of help to someone.
Garrie Powers
IT Developer
Comprehensive Clinical Trials Unit at UCL
Institute of Clinical Trials and Methodology
October 21, 2016 at 8:27 am
g.powers (10/21/2016)
I recently had the same requirement and wrote a function which strips HTML tags and entities regardless of any additional information. I posted the code here at Stack OverflowI hope it is of help to someone.
You should look at the solutions posted in this thread. Yours is a good solution but the performance is going to be pretty painful. You have a scalar function with a while loop. The solutions posted here are set based and will be crazy fast in comparison.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
February 22, 2018 at 12:26 pm
Really stupid question, how do I apply the function? I need to strip html from one column in a table (rq_req_comment).
FROM [test_domain_dgps_export_db].
.[REQ] r
where r.rq_req_comment like '<html>%');
exec dbo.udf_striphtml @HTMLText
]
I get an error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Thanks
February 22, 2018 at 12:48 pm
barry.l.daniel - Thursday, February 22, 2018 12:26 PMReally stupid question, how do I apply the function? I need to strip html from one column in a table (rq_req_comment).
FROM [test_domain_dgps_export_db].
.[REQ] r
where r.rq_req_comment like '<html>%');
exec dbo.udf_striphtml @HTMLText
]
I get an error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.Thanks
The problem isn't the function it is your code. When you use SET to assign a variable and use a query to get the value that error is returned when the query returns more than 1 row. In other words you have more than 1 row in test_domain_dgps_export with a comment that starts with <html>. How could the query engine know which row you want?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply