17

I don't want to hit the database frequently based on page request, so I planned to create a xml file using separate C# coding [exe file] & put in the common path to access from different page/project, which will do the hitting stuff's daily morning, so can you explain how do I execute exe file from sql job or agent by scheduled manner?

My scenario: database table will be updated only once, so I am going for a XML/txt file.

Thanks, S.Venkatesh

Alberto De Caro
  • 5,147
  • 9
  • 47
  • 73
user1531248
  • 521
  • 1
  • 5
  • 17

2 Answers2

31

Executable and batch files may be added to a job as step (MSDN Implement Jobs).

  1. Create a job
  2. Add a new step

2.1 set "Operating system(CmdExec)" as type

2.2 set the executable path

enter image description here

Alberto De Caro
  • 5,147
  • 9
  • 47
  • 73
7

If you must do it in JOB: xp_cmdshell xp_cmdshell execute as nonadmin!

DECLARE @command varchar(8000)
SET @command = 'C:\MyProgram' 
EXEC master..xp_cmdshell @command

But you should shedule task in windows.

VoonArt
  • 884
  • 1
  • 7
  • 21
  • Task Scheduler is better because it lets you run it under a specific domain account that may not be a user in SQL Server – Kyle Johnson Jan 26 '18 at 20:26