x
login about faq Site discussion (meta-askssc)

Jobs with Parameters

Hi,

I would like to know if it is possible to pass in parameters to a sql server Job.I am planning to execute the Job from c#.net.

Thanks, Kannan

more ▼

asked Oct 18 '10 at 06:31 AM in Default

aRookieBIdev gravatar image

aRookieBIdev
2k 24 39 46

(comments are locked)
10|1200 characters needed characters left

4 answers: sort voted first

Please check this link

link text

more ▼

answered Oct 18 '10 at 09:05 AM

Leo gravatar image

Leo
1.6k 48 54 58

(comments are locked)
10|1200 characters needed characters left

What exactly do you want to achieve by executing a job from C#? A job is basically just a method of packaging up something to run - and you could run it more directly using the inbuilt classes in the SqlClient namespace if you were running it through code directly. So - why do you want to execute a job from code?

more ▼

answered Oct 18 '10 at 07:23 AM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.2k 56 63 87

(comments are locked)
10|1200 characters needed characters left

I have used the exec [msdb].dbo.sp_update_jobstep to dynamically change the Job step in my stored procedure.This enable me to change the parameter in the job step as well. In my case I am using a package in the Job step, I can set the package variable
in @command variable like /SET package.variables[Period].Value;2

I would rather call the package directly from my c# code using Microsoft.SqlServer.Dts.Runtime.Unfortunately these ssis objects are not available in my webserver.I was only allowed to call a stored procedure through a web service.Hence I ended up with this method :(

Thank You, Kannan

more ▼

answered Oct 19 '10 at 07:53 AM

aRookieBIdev gravatar image

aRookieBIdev
2k 24 39 46

(comments are locked)
10|1200 characters needed characters left

You can execute a DTSX package passing in variables. Might be an option:

Check this link

more ▼

answered Oct 18 '10 at 07:54 AM

ozamora gravatar image

ozamora
1.4k 2 3 5

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x599
x272
x83
x9

asked: Oct 18 '10 at 06:31 AM

Seen: 925 times

Last Updated: Oct 18 '10 at 06:31 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.