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
To start a jobExpand SQL Server Agent, and expand Jobs. Depending on how you want the job to start, do one of the following: If you are working on a single server, or working on a target server, or running a local server job on a master server, right-click the job you want to start, and then click Start Job.
There are only two ways that someone can have permission to execute a SQL Agent job. You must either own the job, or be a member of the role SQLAgentOperatorRole (found in msdb). Unfortunately SQLAgentOperatorRole grants permissions to run any job (among other things).
SQL Server Agent is a Microsoft Windows service that runs scheduled administrative tasks that are called jobs. You can use SQL Server Agent to run T-SQL jobs to rebuild indexes, run corruption checks, and aggregate data in a SQL Server DB instance.
Executable and batch files may be added to a job as step (MSDN Implement Jobs).
Add a new step
2.1 set "Operating system(CmdExec)" as type
2.2 set the executable path
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With