viv_acious
viv_acious

Reputation: 2489

ASP.NET - run SQL Agent in background

I need to start up a SQL Agent job when I click on some buttons on my ASP.NET page.

How do I let the job run in background without letting my ASP.NET page wait for the job to finish?

The idea is that one the button is clicked, the SQL Agent job does it's own stuff in the background without affecting my page.

I have something like this now:

SqlCommand cmd = new SqlCommand(“EXEC sp_start_job @Job_Name = ‘” + JobName + “‘”, conn);
cmd.CommandTimeout = 30;
cmd.ExecuteNonQuery();

Upvotes: 0

Views: 1088

Answers (2)

Jake Anderson
Jake Anderson

Reputation: 241

'sp_start_job' should be asynchronous by nature and it won't wait for the job to complete.

Upvotes: 1

Vishal Suthar
Vishal Suthar

Reputation: 17194

You can use Asynchronous procedure execution

Upvotes: 1

Related Questions