question

aRookieBIdev avatar image
aRookieBIdev asked

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
sqlsql-serverjob.net
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Leo avatar image
Leo answered
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image
Matt Whitfield answered
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?
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ozamora avatar image
ozamora answered
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
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

aRookieBIdev avatar image
aRookieBIdev answered
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
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.