x

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, 2010 at 06:31 AM in Default

aRookieBIdev gravatar image

aRookieBIdev
2.3k 53 57 62

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

4 answers: sort newest
more ▼

answered Oct 18, 2010 at 09:05 AM

Leo gravatar image

Leo
1.6k 54 56 58

(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, 2010 at 07:53 AM

aRookieBIdev gravatar image

aRookieBIdev
2.3k 53 57 62

(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][1]

[1]: http://www.mssqltips.com/tip.asp?tip=1395
more ▼

answered Oct 18, 2010 at 07:54 AM

ozamora gravatar image

ozamora
1.4k 2 3 5

(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, 2010 at 07:23 AM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.5k 61 65 87

(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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

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

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x738
x346
x87
x12

asked: Oct 18, 2010 at 06:31 AM

Seen: 2535 times

Last Updated: Oct 18, 2010 at 06:31 AM