I have a SQL field that stores HTML such as this:
Table: Template
Fields: NotificationId (int), Template (varchar(max))
Example row: NotificationId 1, Template The template field contains HTML in this form:
<body>
<table border="1">
<tr><td>{RESULTFLD:0:customer_name}</td></tr>
<tr><td>{RESULTFLD:1:customer_address1}</td></tr>
<tr><td>{RESULTFLD:2:customer_address2}</td></tr>
</body>
</table>
What I need to do is parse this somehow where I want to get if possible the NotificationId then a list of each field name in the HTML. For example:
NotificationId 1, then each field name with a line break if possible customer_name customer_address1 customer_address2
Tricky part seems to be the number of the result field increments so trying to parse this HTML to get those values.
Thanks for any help if this seems doable.
1条答案
按热度按时间yqlxgs2m1#
Here is a query which should achieve your requirement. As noted in the comments, however, just because you can it does not mean you should. Doing this in SQL is always going to be hacky.