I've created a page where our partners can upload excel files with statistics using SQLBulkCopy. The file has multiple sheets and I need to add the name of the sheet into a column in the DB for each row. The names of the sheets will not change so hardcoding the names is ok. How can I solve this?
As the name of the sheets doesn't change I solved it this way:
Created a temporary table with the same layout as the final.
Imported the data from the first sheet to temporary table.
Filled the column which was now null with the correct value.
Did nr 2->3 for the next sheet until all sheets were imported.
Checked the temporary table for errors.
Imported the data from the temporary table to the final table one row at the time to be able to spot if the records already exist and if so update it, else insert it.