Re: Trigger a .EXE from SQL Server



Running out of process actions like the file system creation is discouraged in a trigger. A better method, would be to execute the insert through a stored procedure, with the directory creation and the insert being called in some order. Then the lock held on the insert will be much shorter, resulting in less chance of bogging down the whole operation.
--
Rick Byham (MSFT)
This posting is provided "AS IS" with no warranties, and confers no rights.

"Russell Fields" <russellfields@xxxxxxxxxx> wrote in message news:u8$vVXpqHHA.4740@xxxxxxxxxxxxxxxxxxxxxxx
Jon,

In your trigger, provided that it is enabled for non-sysadmin use, you can use the xp_cmdshell procedure to issue an operating system command line statement. This will, of course, cause a small delay in the completion of your insert statement. (But xp_cmdshell has security issues.)

If you can stand a minute or two of asynchronous delay you might do something like the following.
1. Create a SQL Agent job to run the EXE.
2. Post enough data in the inserted table or in another table if necessary to describe with directories still need to be created.
3. From your trigger issue an sp_start_job 'jobname'

This will run asynchronously from the trigger, allowing the trigger to complete. If you are using SQL Server 2005 you can grant the job the needed security context using a SQL Agent proxy account.

RLF
"Jon Rowlan" <jon.rowlan@xxxxxxxx> wrote in message news:O61bdrmqHHA.4132@xxxxxxxxxxxxxxxxxxxxxxx
Is it possible to trigger a .EXE program to run on a Row insertion ...

I want to run an .EXE program whenever a new row is inserted to create a directory somewhere on the server.

I know that there are triggers that I can use but these seem to be to execute SQL statements ...

many thanks all,

jON





.



Relevant Pages

  • Re: Assistance creating my first trigger
    ... Another possibility is to have a SQL Agent job set up to execute your stored ... > execute a proc in order to send email from the trigger. ...
    (microsoft.public.sqlserver.server)
  • Re: Trigger a .EXE from SQL Server
    ... In your trigger, provided that it is enabled for non-sysadmin use, you can ... Create a SQL Agent job to run the EXE. ... If you are using SQL Server 2005 you can grant the job the needed ... I want to run an .EXE program whenever a new row is inserted to create a ...
    (microsoft.public.sqlserver.connect)
  • [NEWS] Multiple Vulnerabilities in Oracle Database (Trigger, Extproc, Wrapped Procedures, PL/SQL Inj
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... Multiple vulnerabilities were discovered in the Oracle database server. ... Oracle Trigger Abuse ... written in PL/SQL and execute with the privileges of the definer/owner. ...
    (Securiteam)
  • Re: Stored procedure/trigger and scripts
    ... must have been the trigger that locked up the table. ... SQL Server has permissions to execute xp_cmdshell. ... >> client to change their password they have to call the "Client Relations" ...
    (microsoft.public.sqlserver.programming)
  • Re: Stored procedure/trigger and scripts
    ... I just ran some additional tests and it looks like my trigger is fine. ... SQL Server has permissions to execute xp_cmdshell. ... >> client to change their password they have to call the "Client Relations" ...
    (microsoft.public.sqlserver.programming)

Loading