SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Execute application on any data change
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

deathwes
Starting Member

4 Posts

Posted - 06/05/2013 :  11:01:11  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 06/05/2013 :  14:39:15  Show Profile  Reply with Quote
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 - 06/05/2013 :  16:41:00  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 06/06/2013 :  00:00:50  Show Profile  Reply with Quote
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 - 06/06/2013 :  09:57:12  Show Profile  Reply with Quote
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 - 06/10/2013 :  10:10:37  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 06/10/2013 :  10:20:16  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000