I have a dynamic excel sheet that’s connected to stock market prices. From a named range in this sheet, I want to trigger any row change to export selected columns as a new record in a database table.
This will be out for a lot of excel rows data changes that are to be inserted into a database table.
- What is best Technique for a robust and reliable connection?
- Any examples or tutorials for on change row exports to sql?
There are several approaches you can take. You could set up a job to call your SSIS package to import your spreadsheet every X number of minutes or hours into a staging database table before going forth to a final table. The process of taking importing and adding new or updating existing information would then be performed using a SQL Task that applies a MERGE command, like that below. In this example the Row1 field is the unique value for each record (TestID is an autoincrementing primary key unique to the database table Tests). You could also use a combination of fields to define each record uniquely. While you did not request this, it is a good idea to include a history table to track changes and maintain traceability.
In the above example, the Tests_import table is the temporary staging table, the Tests table is the final import location and Tests_History tracks the history for each unique record. When the process is complete, then you can either delete the contents of Tests_import or set that as the first step applied in the SSIS package. This way you can compare the initial import with the final Tests table in case there are any issues prior to running the SSIS package again.
Hope this helps.