Peter,
No joy. That ran the Sproc without error, but it inserted all NULL values in every column of the table - nothing imported from the xml spreadsheet. Looks like the 5th select, see below, has issue.
Results tab in debug mode;
1st and 2nd select
- ExcelColNum 0
3rd and 4th select column headers: RID, Data, CellIndex, RowID
- Data column displays the data from the xml sheet
5th select column headers: ColumnID, ColumnName, ExcelColNum, DataTypeName, IsNullable
- have these values: 119 Suffix 117 varchar(max) 1
6th select column headers: all column names from table
- Data in columns are all NULL
Sproc Code:
IF @DataTableExists=1
BEGIN
-- Check whether the data table has columns that is NOT NULL and is not defined in the Excel sheet
IF EXISTS(SELECT 1 FROM #Columns c WHERE c.ExcelColNum=0 AND c.IsNullable=0)
BEGIN
RAISERROR(N'Some non-nullable columns defined in the table [%s] does not exist in the Excel worksheet [%s].',16,1,@OutputTableName,@WorkSheetName);
END
DELETE #Columns WHERE ExcelColNum=0;
END