Executing a trigger before SQL Server table is updated |
 |
EXPERT RESPONSE FROM: Greg Low

|
 |
|


|
| > |
QUESTION POSED ON: 11 September 2007
Can I execute a trigger before an insert is created to a table. I need to create logging on the CRM system, but I do not have access to modify the CRM. Can I grab incoming values from the table and based on the ID, read and extract with a trigger before the table is updated?
|
|
|
To continue reading for free, register below or login
To read more you must become a member of SearchSQLServer.com
');
// -->

You can, by creating an INSTEAD OF TRIGGER. However, I suspect you're really asking about an UPDATE trigger (by your description). Even AFTER triggers (ie the default type) allow you access to both the before and after versions of the data via the deleted and inserted virtual tables.
| Check out this helpful tip: |
|
Optimize database triggers in SQL Server 2000
It's hard to follow the logic behind triggers and easy to forget about them in time. Why and when should you use them? Learn about performance issues and design considerations.
|
|
|
|

|
|
 |

 |
 |
Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and
answer pairs from more than 250 TechTarget industry experts.
|
 |
 |
 |
|
 |
 |
 |
|
 |
|
 |