Hi Ather.Abbas,
We can call the sp_start_job stored procedure to start a job. This is the detail:
http://msdn.microsoft.com/en-us/library/ms186757(SQL.90).aspx.
This sample shows how to call a stored procedure in VB.Net:
'Create a connection.
Dim connectionString As String = "Data Source=localhost;Initial Catalog=MyDB;Integrated Security=True"
Dim con As SqlConnection = New SqlConnection(connectionString)
'Open the connection.
con.Open()
'Create the command
Dim cmd As SqlCommand = New SqlCommand()
cmd.CommandText = "sp_start_job"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@job_name", "N'Weekly Sales Data Backup'")
'Execute the command.
cmd.ExecuteNonQuery()
'Close the connection.
con.Close()
These are some links about Sql Server Agent Job:
1. How to: Schedule a Job (SQL Server Management Studio):
http://msdn.microsoft.com/en-us/library/ms191439.aspx.
2. How to: Create a Transact-SQL Job Step (SQL Server Management Studio):
http://msdn.microsoft.com/en-us/library/ms187910.aspx.
Let me know if this helps.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.