Use Triggers Or Not In SQL Server?

in #data5 years ago

Check out the discussion in the video TSQL: What Are the Disadvantages of Using Triggers. One of the troubles with triggers involves troubleshooting - pay attention to the point made in the video. In addition, keep in mind that we may accidentally create an OLPT environment with transactions (think of a compounding effect with transactions).

Automating ETL
Check out the highest-rated Automating ETL course on Udemy, if you're interested in data.

In the past, I've seen an issue that arose because of what I mention in the video. As a note, the architecture behidn it was appropriate (as is often the case). However, because of the inherent reactive design (mentioned in the video), this was overlooked. There are better alternatives, especially when we consider what architects tend to use triggers to solve for in SQL Server.

YouTube | Automating ETL | T-SQL In 2 Hours | Consumer Guide To Digital Security

Sort:  

There are several uses for triggers in SQL Server, including the following:

  • Performing additional checks on the affected table while performing insert, update, or delete actions.
  • They allow users to encode sophisticated default values that default constraints can't handle.
  • All databases must have referential integrity.
  • If you have a view that uses many tables, you may use these controls to fine-tune what happens when you conduct an insert, update, or delete operation.
  • The use of triggers allows you to create a table with aggregated columns that you may manipulate.
  • Using triggers in auditing and enforcing business rules is the best option. It is possible to keep track of table modifications by creating an audit log record that contains information about the user who made the change and what was modified using a trigger.
    You can also use a stored procedure, but if you do so, you won't be able to log changes that were made directly to the database. It is worth mentioning that a helpful SQL Manager will automate a lot of processes.

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.083
BTC 62762.14
ETH 1674.04
USDT 1.00
SBD 0.42