For auditing purposes, I need to get the unique transaction id from inside the current transaction. I will log the mapping between this transaction id and the application specific session id in a table. Then when looking at the transaction logs, I can find out which application session is responsible for a change in a row.
But it seems that transaction id is not unique for the database and is reset to 0 after a server restart. Querying sys.dm_tran_current_transaction proves so.
So, how can I get such a unique id for a transaction in the transaction logs? Or should I use SQL server audit? Is there a way to query the audit id from inside the transaction?