Trigger EXE each time a record is added

  • I have designed some rather complex Access databases, but I am a total novice iwth SQL Server. What I need to do, is to execute a given EXE file every time a record is added (by a third party through an ODBC connection) to a SQL Server Express database.

    I suspect that this is a very simple task - but I do not even know how to start with it! Would any of the viewers take pity with me and explain to me what (and how) I have to do in orde to reach this goal? I promise perennial gratitude - as well as reciprocation of the help in case you might necessitate my professional skills (diagnostic pathology of the nervous system).

  • Long story short, don't do it.

    If you absolutely have to. Run a service or a job that polls a queue table for "records to process" and then process them. Doing that in a trigger is just asking for trouble.

    What does that exe do anyways?

  • WOW, that was fast! Many, many thanks. The executable is, at the moment, just a BLAT.EXE command that sends a bunch of emails. Later , however, more sophisticated things will happen...

  • aagaag (5/31/2011)


    WOW, that was fast! Many, many thanks. The executable is, at the moment, just a BLAT.EXE command that sends a bunch of emails. Later , however, more sophisticated things will happen...

    As I said, turn that exe into a service that polls a queue table and process those records.

    Plan b might be to use database mail. Same principle... have a job run every x minutes. Select from queue table and mail everything out.

    However since you already have an exec working correctly it might be easier to just modify that instead of rewriting the whole thing in a sql job.

  • This could be done through calling a .NET CLR trigger, but it's not a good idea. Better bet is, as already mentioned, set up a queue and a job and run the job every few minutes.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply