String_To_HtmlTable
Converts delimited data string (such as CSV) to an HTML Table
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT SQLHTTP.net.String_To_HtmlTable ( @String, @ColDelimiter, @RowDelimiter )
Name | Type | Description |
---|---|---|
@String | nvarchar(MAX) | String expression containing substrings and delimiters |
@ColDelimiter | nvarchar(4000) | One or more characters to be used as a column separator |
@RowDelimiter | nvarchar(4000) | One or more characters to be used as a row separator |
xml
This example demonstrates converting the content of a comma-delimited string to an HTML Table:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
DECLARE @String nvarchar(MAX) DECLARE @ColDelimiter nvarchar(4000) DECLARE @RowDelimiter nvarchar(4000) SET @String = 'From City,To City,Distance In Miles' + CHAR(13) + 'Minneapolis,Dallas,864.89' + CHAR(13) + 'New York City,San Francisco,2568.57' SET @ColDelimiter = ',' SET @RowDelimiter = CHAR(13) SELECT SQLHTTP.net.String_To_HtmlTable(@String, @ColDelimiter, @RowDelimiter) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<table> <tr> <td>From City</td> <td>To City</td> <td>Distance In Miles</td> </tr> <tr> <td>Minneapolis</td> <td>Dallas</td> <td>864.89</td> </tr> <tr> <td>New York City</td> <td>San Francisco</td> <td>2568.57</td> </tr> </table> |