I'm new to SQL Server and I have situation that I want to instantly receive inserted data to my web service url.
So I want to create a trigger in SQL Server to send all inserted data to my web service url.
Can you please help me with this.
I'm new to SQL Server and I have situation that I want to instantly receive inserted data to my web service url.
So I want to create a trigger in SQL Server to send all inserted data to my web service url.
Can you please help me with this.
Calling a service from trigger is really a bad idea. Even you should avoid calling any service from SQL Server, it should be done from outside the SQL server. You can implement your requirement by following way.
On every insert, using trigger store the newly inserted row inside a table (queue) for processing by some background job. This will make sure that your insert performance will not impact and chances of failure will be minimum.
You can choose one of the below option.
Processing Service : You can create a windows service, which will pool the queue table, it will pick the pending items and will call the required service. After successfully completion it should updated the queue status to processed.
SQL Job : Write a SQL job and schedule it to run after a fixed interval of time like (1 minute). This job will pick the pending items from your queue table and will use the CLR stored procedure sp_OACreate to call the service.
This will not be real time, but more reliable option with less chances of failure. You can make to near real time by increasing the frequency of job/service.