Worksheet_To_Table

Extracts data from an Excel Worksheet

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

Syntax:

EXEC SQLHTTP.net.Worksheet_To_Table @WorkbookPath, [@SheetName], [@CellRange], [@FirstRowContainsHeaderNames], [@DecimalPrecision], [@DecimalScale], [@DisplayTableDefinition]

Arguments:

Name Type Description
@WorkbookPath nvarchar(4000) Required. The path to a Microsoft Excel Workbook
@SheetName nvarchar(4000) Optional. Name of an existing Worksheet contained in the above Workbook. Default: Sheet1
@CellRange nvarchar(4000) Optional. The range of cell to be extracted in a format such as A1:AB99. If no CellRange is provided, the whole Worksheet is selected.
@FirstRowContainsHeaderNames bit Optional. Indicates whether the first row consists of column headers. Default: 1 (true)

0 = First row does NOT contain column names and will therefore be generated automatically (ex. F1, F2, F3, etc.)
1 = First row CONTAINS columns names

@DecimalPrecision tinyint Optional. The decimal precision that that non-integer values will be retrieved as. Default: 18
@DecimalScale tinyint Optional. The decimal scale that that non-integer values will be retrieved as. Default: 4
@DisplayTableDefinition bit Optional. Indicates whether to output a table definition of the returned table. Create 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)

Remarks:

SQL Server 64 Bit Instances: This function requires the “Microsoft Access Database Engine 2010 Redistributable.” Please see the following for more information: https://www.microsoft.com/en-us/download/details.aspx?id=13255

Sample Usage:

Extracting data from a Worksheet cell range where column names are present
Extracting data from a Worksheet cell range where column names are missing
This example demonstrates obtaining table definition of data retrieved from Excel

See Also: