Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to pass a parameter to trigger in SQL Server database?

Table can have trigger on insert/delete/update. Trigger will be fired internally by DB engine.

Is it possible to pass a parameter to trigger in SQL Server database like a stored procedure?

like image 210
KentZhou Avatar asked Oct 07 '10 16:10

KentZhou


People also ask

Can we pass parameter to trigger in SQL Server?

you can't pass a variable into a trigger. the only way to get the information in the trigger is to be able to SELECT it based on the INSERTED or DELETED tables or add a column onto the affected table and put the value in that column.

Can we pass parameter to function in SQL?

We can also pass dates as parameters in the SQL Server functions. In this section, we will create a function that will take a particular date as the input parameter.

Which is not allowed in a trigger?

Since triggers execute as part of a transaction, the following statements are not allowed in a trigger: All create commands, including create database, create table, create index, create procedure, create default, create rule, create trigger, and create view. All drop commands. alter table and alter database.

Can we pass parameter to trigger in Oracle?

A) Yes they can, we're talking about nested triggers.


1 Answers

Indirectly via CONTEXT_INFO(). See Using Session Context Information. The fact that your trigger needs extra state is always a code smell.

like image 113
Remus Rusanu Avatar answered Oct 05 '22 21:10

Remus Rusanu