Discussion:
How to cast an event outside
(too old to reply)
Sandro Santucciu
2012-01-25 13:33:34 UTC
Permalink
Hello there, i'm new here. I am a young DB admin, my workmates here have just asked me to do something I have never done before: they want to substitute their polling procedures, developped in C# and Silverlight in a Visual Studio 2010 Environment, with a trigger in SQL Server 2008 RD2 that, for each record inserted, could cast an event outside so they know if a table has been update recently without keep checking the database.
Do someone has a hint on how to do this? Is this possible anyway?

Regards,
Thank you.
Andrew Morton
2012-01-25 15:02:05 UTC
Permalink
Post by Sandro Santucciu
Hello there, i'm new here. I am a young DB admin, my workmates here
have just asked me to do something I have never done before: they
want to substitute their polling procedures, developped in C# and
Silverlight in a Visual Studio 2010 Environment, with a trigger in
SQL Server 2008 RD2 that, for each record inserted, could cast an
event outside so they know if a table has been update recently
without keep checking the database. Do someone has a hint on how to
do this? Is this possible anyway?
This might be of some use:

"Build Apps that Provide Real-Time Information and Customized Content Using
SQL Server Notification Services"
http://msdn.microsoft.com/en-us/magazine/cc188913.aspx
--
Andrew
Erland Sommarskog
2012-01-25 15:47:19 UTC
Permalink
Post by Andrew Morton
Post by Sandro Santucciu
Hello there, i'm new here. I am a young DB admin, my workmates here
have just asked me to do something I have never done before: they
want to substitute their polling procedures, developped in C# and
Silverlight in a Visual Studio 2010 Environment, with a trigger in
SQL Server 2008 RD2 that, for each record inserted, could cast an
event outside so they know if a table has been update recently
without keep checking the database. Do someone has a hint on how to
do this? Is this possible anyway?
"Build Apps that Provide Real-Time Information and Customized Content
Using SQL Server Notification Services"
http://msdn.microsoft.com/en-us/magazine/cc188913.aspx
SQL Server Notification Server is a deprecated product and its not
involving. It would not be a good idea to use it.

It would be possible to implement a trigger in the CLR, which distributes
this event. However, it would not be a good idea. A trigger should execute
quickly, as it executes in the realm of a transaction where you hold locks.
Also, the idea with a trigger is that if it fails, the statement fails. What
is the event cast fails because the receiver is down. Do you want a rollback
in this case?

A better solution is to put a message on a Service Broker queue. Then you
can have various solution on the other end of the queue. You could have a
stored procedure that performs the event-casting. You could also have
external activation, and, yes that essentially means polling. Except that
you can make a call which will wait until something happens.
--
Erland Sommarskog, SQL Server MVP, ***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Sandro Santucciu
2012-01-25 16:53:09 UTC
Permalink
Thank you Mr. Morton your answer was quite useful. I was thinking to use a Service Broker too, but my workmates believed the trigger could be much of use; now that they know it involves a transaction too they want to stuck with polling again because is already done.

Thank you again, bye.
Andrew Morton
2012-01-26 09:17:24 UTC
Permalink
Post by Sandro Santucciu
Thank you Mr. Morton your answer was quite useful. I was thinking to
use a Service Broker too, but my workmates believed the trigger could
be much of use; now that they know it involves a transaction too they
want to stuck with polling again because is already done.
I'd go with any answer Erland gives over suggestions I might make regarding
SQL any day of the week.
--
Andrew
Loading...