I have a transactional-replication running in my database, and I need to execute a service on my website that refreshes the cache every time the database changes.

So i guess i have two options to make it work.

  1. Execute job when transactions occur
  2. Execute a job on every database change

But i have no idea how to do either of those. Is it even possible? I have been looking around and it seems that the "on-transaction" event, is not really possible because the replication agent is not starting and stopping, it's just running the whole time.

And executing a job on every database change should be possible, but again, never tried it before, but i really would bet money on it being possible.

Anyone know how this can be done? Thanks in advance :)


I have two sets of servers, two webservers and two database servers. The db-server has transactional replication to the other db.

Each webserver has it's own website running with some pretty deep caching. I need to trigger a cacherefresh webservice on the webserver so that the replicated changes will be visible to users.

Yesterday after writing this question, i set up a scheduled job to refresh the cache, and if this works wothout any hicks, i would rather keep that solution going, but if not i will need to trigger the refresh some other way.

Thank you :)

  • Could you explain more about the "every time database changes"? Are you referring to data changes in the source tables?
    – Sky
    Oct 30 '12 at 0:34
  • 2
    This sounds, um, dangerous. You want to run a job after every data-changing transaction in your database? Oct 30 '12 at 3:06
  • You are right, this could easily backfire without some kind of throttling
    – Moulde
    Oct 30 '12 at 8:42
  • This question seems similar to this: stackoverflow.com/questions/8658629/… Oct 30 '12 at 14:15

In sql server database level triggers comes in handy like this situation , you can call job to start and leave inside the trigger like

ON dbo.TableName
    EXEC dbo.sp_start_job N'jobname'
  • This seems like a way to do it, this may be the way i chose to do it if the current more simple solution doesn't work out.
    – Moulde
    Oct 30 '12 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.