Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

SQL Server Tutorial : Trigger alternatives

Автор: DataCamp

Загружено: 2020-04-12

Просмотров: 1093

Описание:

Want to learn more? Take the full course at https://learn.datacamp.com/courses/bu... at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.

---

So far we've talked about the types of triggers and the scenarios that best fit their use.

But as with any feature, triggers are not always the best solution in SQL Server.

In this lesson we will compare triggers with other objects and take a look at the appropriate situations for using them.

The first comparison of triggers is with regular stored procedures.

The trigger is a stored procedure as well, but a special kind. What makes it so special?

A trigger is fired when a defined database or server event occurs.

Regular stored procedures run when called explicitly. A trigger runs only when the event that fires it is starting.

Triggers don't allow input parameters or transaction statements (like BEGIN TRANSACTION or COMMIT). They also cannot return output values.

On the other hand, regular stored procedures allow input parameters, transaction statements, and the possibility to return output.

These considerations impact the real-life use cases for triggers and regular stored procedures.

We use triggers for audit and to enforce integrity in most cases, and we use regular stored procedures for more general tasks.

The second comparison of triggers is with computed columns.

Computed columns are a good way to automate the calculation of the values contained by some columns.

Computed column values are determined based on values from other columns, but only from the same table.

This limitation can be overcome by using triggers.
A trigger can use columns from other tables as well to calculate values.

While this calculation will be done with INSERT or UPDATE statements when using a trigger, for a calculated column it will be part of the table definition.

In this example, the column "TotalAmount" is a computed column.
Its value comes from the multiplication of the "Quantity" and "Price" columns from the same table.

But if those two columns were not part of the same table, we wouldn't be able to do the calculation using a computed column.

In that case, we could replace the computed column with this trigger definition.

Here, the Price column is not part of the "SalesWithoutPrice" table. The trigger determines the "TotalAmount" by using the "Price" column from another table ("Products" in this example).

Now that you've seen how triggers can substitute for other database objects, let's see how to use them in practice.

#DataCamp #SQLServerTutorial

SQL Server Tutorial : Trigger alternatives

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Неизбежная эволюция SQLite

Неизбежная эволюция SQLite

How to Import CSV and Excel Files in RStudio | Complete Beginner Tutorial

How to Import CSV and Excel Files in RStudio | Complete Beginner Tutorial

2026-01-09 Копирование таблицы в CSV или Markdown

2026-01-09 Копирование таблицы в CSV или Markdown

Build a Multi-AI Agents System for Financial Analysis

Build a Multi-AI Agents System for Financial Analysis

Triggers Error Entity Framework Core 7 (.NET 7)

Triggers Error Entity Framework Core 7 (.NET 7)

Breaking Down What a Program Actually Is

Breaking Down What a Program Actually Is

To już nie kryzys, a faktyczny rozpad: Bosak grzęźnie w Collegium Humanum, Mentzen chwali Tuska

To już nie kryzys, a faktyczny rozpad: Bosak grzęźnie w Collegium Humanum, Mentzen chwali Tuska

The People versus Microsoft

The People versus Microsoft

Laziest Way to Make Money with AI (Starting From Zero)

Laziest Way to Make Money with AI (Starting From Zero)

Sytuacja KRYTYCZNA Na Ukrainie! Wybuchła POTĘŻNA Afera Korupcyjna. Koniec ZELENSKIEGO?

Sytuacja KRYTYCZNA Na Ukrainie! Wybuchła POTĘŻNA Afera Korupcyjna. Koniec ZELENSKIEGO?

The Windows 11 Disaster That's Killing Microsoft

The Windows 11 Disaster That's Killing Microsoft

‘Insult To Indian Scientists’: PM Modi Fumes Over China Flag In DMK’s ISRO Ad | Watch

‘Insult To Indian Scientists’: PM Modi Fumes Over China Flag In DMK’s ISRO Ad | Watch

Beware the Hidden Side Effects of SQL Server Triggers

Beware the Hidden Side Effects of SQL Server Triggers

Rug Pull How To Work? How To Launch Solana Meme Coin

Rug Pull How To Work? How To Launch Solana Meme Coin

Wyjaśniamy o co chodzi z Grenlandią. Czy naprawdę może wybuchnąć wojna USA-Dania?

Wyjaśniamy o co chodzi z Grenlandią. Czy naprawdę może wybuchnąć wojna USA-Dania?

SQL indexing best practices | How to make your database FASTER!

SQL indexing best practices | How to make your database FASTER!

SQL Server Programming Part 14 - Transactions

SQL Server Programming Part 14 - Transactions

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com