start operating system command when new inserts

  • Hi All,

    I've this problem, I need to watch 1 table. Whenever there is new insert to the table, I need to execute a system command (CmdExec). I tried using trigger on the watch table, but you can only use T-SQL stmts in trigger.

    any ideas???

    Thanks

    Ku

  • A couple solutions:

    1. Insert a value in a table using a trigger. Run a DTS package every 10 sec, check for new values and run the command

    2. Use master..xp_cmdshell. It will allow you to run OS commands.

    Steve Jones

    steve@dkranch.net

  • Steve,

    in option 2, you mean I can use the EXEC master..xp_cmdshell 'command ...' within the trigger on the watch table, correct?

    I think I'm close!

  • you will have to be careful about permissions and for that reason I would not do it, but yes, you can

    create trigger mytrigger on mytable for insert

    as

    exec master..xp_cmdshell 'dir c:'

    Steve Jones

    steve@dkranch.net

Viewing 4 posts - 1 through 3 (of 3 total)

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