executing a program in a trigger in MS SQL Server


Is it possible to execute a program (win32) from a trigger?  I want to do some external work after 10 records have been inserted in a table.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You should be able to run an xp_cmdshell in your trigger to execute your program.


You may have to enable it if it isn't enabled.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
Yes, you can configure xp_cmdshell as mentioned earlier but wont recommend to do so as you might land in some issues..
Having Triggers would impact performance and Calling external program using xp_cmdshell via triggers might add upon to that..

Take care while referencing it..
If possible do it via alternate logics instead of this approach.( recommended)
Anthony PerkinsCommented:
>>Is it possible to execute a program (win32) from a trigger?<<
Can you do it?  Yes.  Should you do it? No.  This is a very bad idea.
soozhCEOAuthor Commented:
well if it is such a bad idea can a some code in a stored procedure execute a stored procedure in another database (same server).
Anthony PerkinsCommented:
I am sorry, I am not understanding you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.