In a SQL Server 2017 or Azure SQL Database database, is there a way to identify rows in the history table that were deleted from the current table, without specifically executing a query that finds all primary key values in the history table that do not exist in the current table? I suspect there isn't but wanted to make sure I'm not overlooking anything.
Asked
Active
Viewed 1,739 times
2
-
That would depend largely on how your "history" table was created. Since it seems you aren't already tracking that I'm going to say probably not see [https://dba.stackexchange.com/questions/9299/track-deleted-rows-records](https://dba.stackexchange.com/questions/9299/track-deleted-rows-records) for methods to actually track deleted rows with the knowledge they are deleted. – R.Laney Feb 16 '18 at 16:21
-
@R.Laney - You are correct. We currently don't have any sort of auditing implementation in place. And, the history table will be created automatically by SQL Server (probably). – Randy Minder Feb 16 '18 at 16:25
-
Possible duplicate of [What is the best way to query deleted records with SQL Server 2016 temporal tables?](https://stackoverflow.com/questions/37151156/what-is-the-best-way-to-query-deleted-records-with-sql-server-2016-temporal-tabl) – Tom Blodget Mar 13 '19 at 16:27