7.0k views
0 votes
Can a Trigger be made to run in User context?

1. Yes
2. No

User Ryflex
by
7.5k points

1 Answer

3 votes

Final answer:

Yes, a trigger can be made to run in user context by using the 'WITH EXECUTE AS' clause. This allows the trigger to access database objects that the user has permission to access.

Step-by-step explanation:

Yes, a trigger can be made to run in user context. When a trigger is created with the 'WITH EXECUTE AS' clause, it runs in the security context of the user who created the trigger. This allows the trigger to access database objects that the user has permission to access.

For example, suppose a user creates a trigger on a table and specifies 'WITH EXECUTE AS OWNER'. This means that the trigger will run in the context of the owner of the table, allowing it to perform actions on the table as if the owner were running the code.

However, it's important to note that running a trigger in user context can have security implications. Care should be taken to ensure that the user running the trigger has only the necessary permissions to access database objects.

User Nilay Singh
by
8.8k points