View Single Post

   
  #4 (permalink)  
Old 02-28-2008, 07:44 PM
Greg D. Moore \(Strider\)
 
Posts: n/a
Default Re: Using xp_cmdshell in INSERT trigger: bad idea?


"Joel Thornton" <joelpt@eml.cc> wrote in message
news:c190a45a.0401272101.258fbedc@posting.google.c om...
> Whenever something is inserted to a given table, I want to run some
> shell commands using xp_cmdshell. Would it be a bad idea to put this
> xp_cmdshell in the INSERT trigger of this table?
>
> I understand that when using xp_cmdshell, the sql thread in question
> waits until xp_cmdshell finishes what it's doing. Does this mean if
> my xp_cmdshell call takes 30 seconds, that nobody else can insert to
> this table until my xp_cmdshell and rest of the insert trigger finish
> up?


Basically yes, you risk locking others out of your table. And what's worse,
if for some reason the external process hangs, your DB is not basically
locked up.

>
> The alternative solution seems to be frequent polling of the table in
> question; while this isn't really a great solution it would seem to
> circumvent a table lock brought about by the INSERT trigger.


It really depends on what you want to do. Polling is one option. Or as
another poster said, possibly a stored proc.

Perhaps if you explain what exactly you want to do in the command shell that
may help.


>
> Thoughts?
>
> Joel



Reply With Quote