Use a Table Variable for Logging Entries that Need to Survive Rollbacks.


Table variables are special types of local variables that can be used to store data temporarily, similar in many ways to temporary tables in SQL Server but they are intended for a different purpose. Temporary tables are physical tables stored in the tempdb database and have statistics and indexes, table variables are logical objects that are stored in memory and have no statistics or indexes.

In a SQL Server database, it is beneficial to have a table where we log entries for the different stages or steps throughout a process so we can review row counts, how much time