Re: Trigger a .EXE from SQL Server
- From: "Rick Byham, \(MSFT\)" <rickbyh@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Jun 2007 09:51:45 -0700
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@xxxxxxxxxxxxxxxxxxxxxxxIs 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
.
- References:
- Trigger a .EXE from SQL Server
- From: Jon Rowlan
- Re: Trigger a .EXE from SQL Server
- From: Russell Fields
- Trigger a .EXE from SQL Server
- Prev by Date: Re: SQL Server Connection problem
- Next by Date: Connecting database server from application server
- Previous by thread: Re: Trigger a .EXE from SQL Server
- Next by thread: SQL Server 2005 with VB.net 2005
- Index(es):
Relevant Pages
|
Loading