|
Home > Archive > MS SQL Server > June 2005 > trigger or stored procedure
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
trigger or stored procedure
|
|
|
| Can trigger or stored procedure launch an exe from c:\whatever?
| |
| Tibor Karaszi 2005-06-02, 9:23 am |
| Yes, through xp_cmdshell. But not if the exe has any GUI, it need to be a console app. And you don't
want to do this from a trigger, as locks are held, etc and spawning processes is not a quick thing
to do.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/
"UGH" <nospam@noSPam.com> wrote in message news:OPd7uY3ZFHA.3364@TK2MSFTNGP09.phx.gbl...
> Can trigger or stored procedure launch an exe from c:\whatever?
>
>
| |
| Jens Süßmeyer 2005-06-02, 9:23 am |
| Yes, using XP_Cmdshell.
--
HTH, Jens Suessmeyer.
---
http://www.sqlserver2005.de
---
"UGH" <nospam@noSPam.com> schrieb im Newsbeitrag
news:OPd7uY3ZFHA.3364@TK2MSFTNGP09.phx.gbl...
> Can trigger or stored procedure launch an exe from c:\whatever?
>
>
| |
| David Portas 2005-06-02, 9:23 am |
| Look at xp_cmdshell or the sp_OA extended procs in Books Online.
Not a good idea to call external programs in a trigger though. Unless
the external process is required to be transactional then it isn't
necessary to put it in a trigger at all - just put it in a proc or have
the process poll the database regularly and check for updates.
If the external process IS required to behave as part of a transaction
then it's still better to keep it out of the trigger. In that scenario
you would probably otherwise want to implement another call outside the
trigger in order to "roll-back" the external process if a nested tran
wasn't committed. If you are going to do that anyway then why not just
do the whole thing without a trigger?
--
David Portas
SQL Server MVP
--
| |
| Alejandro Mesa 2005-06-02, 9:23 am |
| Yes, you can launch an executable file from both, but because a trigger is
fired inside a transaction then it is not recommended to do this inside a
trigger (try to keep your transaction a short as possible). Another cons is
that the program is being executed out of sql server context and if there is
a problem, sql server can not get the control back. For example, if the
program need a user entry in order to continue.
AMB
"UGH" wrote:
> Can trigger or stored procedure launch an exe from c:\whatever?
>
>
>
| |
|
| I would prefer to write them in stored procedure or trigger but my boss does
not want me to rewrite the code if the old application works right. He is
one of those guys that belives in don't fix it if it is not broken.
The application does not have any gui and if there is an error, it will
close out. The exe takes about few seconds to process some information.
"UGH" <nospam@noSPam.com> wrote in message
news:OPd7uY3ZFHA.3364@TK2MSFTNGP09.phx.gbl...
> Can trigger or stored procedure launch an exe from c:\whatever?
>
>
| |
| Anthony Thomas 2005-06-03, 3:23 am |
| Yea, well, tell your boss that thinking just like that is what got the
Challenger blown up.
Since your boss is so fond of quotable quotes, try this one: If it is worth
doing, it's worth doing right, the first time.
Sincerely,
Anthony Thomas
--
"UGH" <nospam@noSPam.com> wrote in message
news:%23eaG5m3ZFHA.3492@TK2MSFTNGP14.phx.gbl...
I would prefer to write them in stored procedure or trigger but my boss does
not want me to rewrite the code if the old application works right. He is
one of those guys that belives in don't fix it if it is not broken.
The application does not have any gui and if there is an error, it will
close out. The exe takes about few seconds to process some information.
"UGH" <nospam@noSPam.com> wrote in message
news:OPd7uY3ZFHA.3364@TK2MSFTNGP09.phx.gbl...
> Can trigger or stored procedure launch an exe from c:\whatever?
>
>
|
|
|
|
|