HtmlTable_To_Table

Returns tabular data derived from an HTML Table

  • Free Stored Procedure
  • SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017

Syntax:

EXEC SQLHTTP.net.HtmlTable_To_Table @HTMLTableAsXMLString, @FirstRowContainsHeaderNames

Arguments:

Name Type Description
@HTMLTableAsXmlString nvarchar(MAX) String containing an HTML Table markup
@FirstRowContainsHeaderNames bit 0 = First row does NOT contain column names and will therefore be generated automatically (ex. Col1, Col2, Col3, etc.)
1 = First row CONTAINS columns names
@StartRow int Default: 1 (true)
@MaxRows int Default: 0 (all rows)
@RemoveDoubleQuotes bit Default: 1 (true)
@DisplayTableDefinition bit Optional. Indicates whether to output a table definition of the returned table and an accompanying insert statement. The table definition will be viewable in the Messages tab of SQL Server Management Studio’s Query Results Pane. See the last example below.
Default: 0 (false)

Table Returned:

Varies, depending on HTML Table columns and data types

Sample Usage:

This example produces tabular data from an HTML Table markup with column names defined in the first <tr> block:
This example produces tabular data from an HTML Table markup with automatically generated column names. It also limits the results to three rows and includes the resulting table definition and accompanying insert statement in the Query Results pane of SSMS:

See Also: