volrO
volrO

Reputation: 13

How to check the correctness of adding records to the transaction log?

I've got database ApressFinancial which i created from the book. (Robin Dewson - Beginning SQL Server for Developers (The Expert's Voice in SQL Server) - 2014)

I was asked a question: "How to check the correctness of adding records to the transaction log?" (And there was Hint that i can use trigger instead of)

Could not figure out. Thank you.

Upvotes: 1

Views: 56

Answers (1)

Alexei - check Codidact
Alexei - check Codidact

Reputation: 23088

I think you need a INSTEAD OF INSERT trigger in order to catch all your inserted data.

Basically, you create a trigger, which is a special type of stored procedure that lets you hook some functionality inside the transaction that should perform the INSERT (instead of will cause the insert intent to not fulfill). The trigger will expose a special table (not sure this is the exact term, but it behaves like one) called inserted that contains the information that is supposed to be inserted.

A more relevant example can be found here.

NOTE: also take a look upon AFTER INSERT trigger, as this type allows values to be inserted and provide a mechanism to use the values to perform other operations.

Upvotes: 1

Related Questions