all groups > sql server notification services > february 2005 >
You're in the

sql server notification services

group:

NS subscription programming question


NS subscription programming question Wyk
2/28/2005 2:11:41 PM
sql server notification services:
I'm new to NS and SQLServer in general.

How would I write a
subscription that would trigger an event whenever any row(s) in a table have
been
updated/inserted/deleted and provide return those row(s) in the notification
message?

In other words, can I set up a subscription that triggers an event whenever
a table's data has been updated and return information of which row(s) those
were?

Thanks,
Wyk

RE: NS subscription programming question James Wu (MSFT)
2/28/2005 3:05:05 PM
What you are really looking for is an event provider that can generate
updated/inserted/deleted events. You can then define an event rule in your
subscription that sends information about the rows that were updated to your
notificaiton class.

There are 2 ways your can define your event provider:

1. Can you use the built-in SQL server event provider? This event provider
runs a T-SQL query and returns rows as events. One way to use it is to add a
"Status" column in your table. Whenever you update your table, you will set
the status to column, and the SQL server event provider will return any rows
that have the status of ""updated", "inserted", or "deleted". You can clear
the status fields in the PostQuery defined in the SQL server event provider.

2. If the above does not server you, consider implementing a custom event
provider.

Hope this helps.

[quoted text, click to view]
Re: NS subscription programming question Joe Webb
2/28/2005 7:10:45 PM
Hi Wyk -

Check out the 4 samples provided with NS setup, particularly the stocks
walkthrough. It does a pretty good job illustrating the dev process.


HTH...
Joe Webb
SQL Server MVP

~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811




[quoted text, click to view]
AddThis Social Bookmark Button