Post by Missy
I am writing to seek some advice/help, as to if its possible to create a
trigger or function in sql server, which can call a specific URL, when a
new record is inserted into the 'employees' table.
if so, any further example or guide, as to how would I go about
implementing this task, which would be great help.
I don't think it is a good idea. When you are in a trigger, you are
executing in the context of a transaction and the rows you have inserted are
locked. A trigger action should be short and swift. Calling a web service is
the antithesis of this.
The main purpose of triggers is:
1) Perform integrity checks that cannot be performed with constraints.
2) Perform cascading updates that are needed for database integrity.
A collorary of this is that if a trigger fails, so does the statement which
fired the trigger.
So that is the question you need to ask yourself: if the web service is
down, should it not be possible to add new employees?
A more reasonable approach would be to have a program that regularly checks
for new inserts into the table. This can be achieved in several ways. Note
that the call to the URL would be performed from this program, and not from
Erland Sommarskog, SQL Server MVP, ***@sommarskog.se
Books Online for SQL Server 2005 at
Books Online for SQL Server 2000 at