Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Execute application on any data change

Author  Topic 

deathwes
Starting Member

4 Posts

Posted - 2013-06-05 : 11:01:11
Hi everyone!

I'm trying to have a batch file execute whenever data is updated in a database. I've found that if I put: cmd.exe /c "c:\test.bat" in a SQL Server Agent job I can execute the batch file, but there doesn't seem to be a way to have this triggered by a record being added, updated, or deleted. Any help on this would be greatly appreciated. Thanks!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-05 : 14:39:15
you might have to do this inside trigger code then using xp_cmdshell to call batch file. But this is not a recommended method
can i ask what you're doing with batch file?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

deathwes
Starting Member

4 Posts

Posted - 2013-06-05 : 16:41:00
I'm generating html code from the new/modified/deleted records and compiling them in to a help desk. I currently have a linked access database checking every 2 seconds for new entries so I feel like anything would be better than that :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-06 : 00:00:50
if your html structure would be fixed you could do it inline inside trigger code itself without having to call a batch process. I hope there's no intermediate steps involved

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

deathwes
Starting Member

4 Posts

Posted - 2013-06-06 : 09:57:12
There are other processes running outside of the html generation, including a command line driven compiling. Do you think you could give me an example of what my trigger code would look like? Maybe using Database1 and Table1 having a trigger for any insert, update or delete that would run "c:\test 1.bat" using xp_cmdshell? Also where would this code be put?
Go to Top of Page

deathwes
Starting Member

4 Posts

Posted - 2013-06-10 : 10:10:37
Is that too much to ask? If anyone knows a good site for putting work like that out to bid that would also be helpful.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-10 : 10:20:16
what i would suggest is to add a logic inside your trigger to capture the details of records being changed in a table. Then execute a periodic job which will pick up records from first table, do processing of records, and call bet to build html etc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -