问题
I have implemented a system versioned (temporal) table on one of our production tables that is frequently updated. This table is updated by applications, power users (manually with custom scripts and standardized sprocs), and system jobs.
I have just run into a situation where I see a new record inserted into the history table but it appears exactly the same as the one before it. As I research this I see it is not a one off situation; there are many more. Please keep in mind the begin and end dates are not duplicated. The end date of the previous record matches the begin date of the next record, with all other data being exactly the same.
I would like to prevent this from happening if possible but first I need to know where this is coming from.
Does anyone have experience with this happening? Does anyone understand temporal tables enough to give me some potential leads on what could trigger an insert into the history table without a visible change to the data? Is it possible to change a record without changing the fields visible to the user?
Thanks in advance.
回答1:
I'm pretty sure an update of the table that doesn't actually change data but still sets it (ie, update table set field1 = field1) will cause a new entry in the history table.
I'm going to guess it's being caused by 'power users' scripts (tends to be the number 1 source of screwy code from my history), though the application may also be responsible. Might be in the range of 'code audit' time to find out where the update is coming from.
来源:https://stackoverflow.com/questions/47084368/sql-server-temporal-table-creating-duplicate-records