Showing posts with label ssis. Show all posts
Showing posts with label ssis. Show all posts

Monday, March 12, 2012

Get the variable from Execute Process Task to C#

Hi!

I need help with some C# code. I have build a SSIS package with an Execute Process Task. I need to send dynamic variables in to my C# program so I thought it was a good idea to use the StandardInputVariable.

How do I get the variable in my C# code?
Thanks

CarlYour Main methods parameter collection?|||

Peter K wrote:

Your Main methods parameter collection?

yes. provided that this functionality has been built into the c# code.|||Thanks for your help.

I tried to get the variable through the main method but it dont work, the only thing I got was the argument.
My test code:
static void Main(string[] args)
{


for (int i=0; i<args.Length; i++)
{
Console.WriteLine(argsIdea);
Console.ReadLine();
}

Carl|||

ctsand wrote:

Thanks for your help.

I tried to get the variable through the main method but it dont work, the only thing I got was the argument.
My test code:
static void Main(string[] args)
{


for (int i=0; i<args.Length; i++)
{
Console.WriteLine(args);
Console.ReadLine();
}

Carl

did you include the variable as an argument to your c# executable in the execute process task?|||I have a static argument and a variable in StandardInputVarable. I put a value in the variable for testing but it will be dynamic.|||

ctsand wrote:

I have a static argument and a variable in StandardInputVarable. I put a value in the variable for testing but it will be dynamic.

is this necessary? can't you just use a dynamically updated ssis variable when calling your executable in the execute process task?|||

My intention was have to have the argument to jump to a special method in the code. The variable will have information about witch rows in the table the code shall read in and treat.

In any case, can I put a dynamic variable in the argument?

Carl

|||

the code below is how to execute package in c# code.the red code tell you how to dymamic edit variable.i think this method can get variable.but i didn't try.please try it

//add reference "Microsoft.SqlServer.ManagedDTS"(in microsoft.sqlserver.manageddts.dll)
Imports Microsoft.SqlServer.Dts.Runtime

Dim pkg As String = "package directory"

Dim app As Application = New Application()
Dim p As Pakage = app.LoadPackage( pkg, Nothing )
p.InteractiveMode = true
Dim pty As DtsProperty

'Dim n As Integer = p.Configurations.Count

Dim strPty As String
For Each pty In p.Properties
strPty = pty.Name & ":"
Try
If pty.Get Then strPty &= pty.GetValue( pty ).ToString()
Catch
End Try
Console.WriteLine( strPty )
Next

Dim vir As Variables = p.Variables
vir( "strFile" ).Value = "C:\MyApp2.txt"

Console.WriteLine( p.Execute( Noting, vir, Nothing, Nothing, Nothing ).ToString() )

|||

ctsand wrote:

My intention was have to have the argument to jump to a special method in the code. The variable will have information about witch rows in the table the code shall read in and treat.

understood

In any case, can I put a dynamic variable in the argument?

Carl

i don't know. did you try?|||

I tried it but it didnt worked. The only thing I got was the name of the variable.

You wrote earlier:

is this necessary? can't you just use a dynamically updated ssis variable when calling your executable in the execute process task?

What did you mean by that?

|||

ctsand wrote:

I tried it but it didnt worked. The only thing I got was the name of the variable.

You wrote earlier:

is this necessary? can't you just use a dynamically updated ssis variable when calling your executable in the execute process task?

What did you mean by that?

what are the option settings in the process page of the execute process task editor?|||

RequireFullFileName = True

Executable = M:\Program\Person.exe

Arguments = fakt

WorkingDirectory = M:\Program

StandardInputVariable = User::test

StandardOutputVariable =

StandardErrorVariable =

FailTaskIfReturnCodeIsNotSuccessValue = True

SuccessValue = 0

TimeOut = 0

TerminateProcessAfterTimeOut = True

WindowStyle = Normal

|||what is the value and data type of User::test immediately before the execute process task starts executing? is the value of this variable correct?|||

The data type is string and the value is testing.

I have a question for you.

Is't meaning that I shall use the main-method to get the argument and the variable?

Carl

Wednesday, March 7, 2012

get SQL connection for SQL config from XML

Hi

In toder to make my SSIS packages portable, I need to be able to set connection string to sql package configuration. I thought I can do that via XML package, problem is, at execution time SQL server package configuration is queried first, then variables from XML.
This way, I have no chance to set connection via XML.
Any ideas on how to aproach this ?
(I want to have as much configuration on SQL server so I can modify it easily from future GUI application.

best regards

For this scenario what you need is an indirect configuration, where the connection string to the SQL Server database where your "real" configurations are stored is in turn stored in an environment variable:

http://dotnetjunkies.com/WebLog/appeng/archive/2006/05/30/indirectconfigpackagessis.aspx

http://blogs.conchango.com/jamiethomson/archive/2005/11/02/2342.aspx

I do not know of any way to perform this indirection through an intermediary XML config file - only environment variables are supported.

|||

One more method:

http://rafael-salas.blogspot.com/2007/01/ssis-package-configurations-using-sql.html

|||You should be able to set your initial SQL Server connection from an XML configuration file. In the Configurations dialog, make sure that the XML configuration is at the top of the list, so that it is executed first.

Sunday, February 26, 2012

Get Server\Instance Name

I can't find this anywhere in the thousands of objects in SSIS. So I thought I would ask.

I have a situtation where I want to retrieve the server\instance name of the SSIS job is running on. I have multiple servers and instances and I want to send emails like "Failed see server\instance - job name".

Any ideas?

Thanks

There is a System variable in SSIS called MachineName that, I think, solves half of what you want.

Rafael Salas

|||

Tom Phillips wrote:

I can't find this anywhere in the thousands of objects in SSIS. So I thought I would ask.

I have a situtation where I want to retrieve the server\instance name of the SSIS job is running on. I have multiple servers and instances and I want to send emails like "Failed see server\instance - job name".

Any ideas?

Thanks

A SSIS package does not run on a server/instance. Each execution is a standalone process (you can see it in Task Manager as dtexec.exe). There is no server component required in order to execute packages.

-Jamie

|||That is true. However the job which kicked off the SSIS package did start on a server. That is actually what I am trying to get.

Maybe I will have to pass it in the job to the SSIS package?|||

Tom Phillips wrote:

Maybe I will have to pass it in the job to the SSIS package?

That might be the way to go...

Rafael Salas

|||

Tom Phillips wrote:

That is true. However the job which kicked off the SSIS package did start on a server. That is actually what I am trying to get.

Maybe I will have to pass it in the job to the SSIS package?

OK, so the job is completely different to the package. There is no way for the SSIS package to know where it was executed from unless you explicitly tell it so yes, you will have to pass it in.

-Jamie

Get Return Value from Stored Procedure

Greetings All,
I am a newbie to SSIS and need some help. I need to get the return value from a stored procedure into a SSIS variable. I'm assuming I would use an OLE DB Command but I havn't a clue on how to capture the return value. Can someone get me started on how I can do this?

Note, the return value is actually an identity of the inserted value. I need this value in my data flow for further processing.

Thanks is advance!If you search this forum you'll find numerous examples and posts on this topic. You'll also want to use the OUTPUT keyword on the stored procedure call.|||I did search the forum and many of them seemed a bit abstract for a beginner. I was hoping someone could lend me the "cliff notes".

Otherwise, I'll keep diggin'.|||http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1001679&SiteID=1|||Thanks Phil.|||Assuming I get the return identity in the output column, how can I then get this value into a IS variable?

Thanks

Friday, February 24, 2012

Get Previous step result in an SSIS Script Task

Hello,

I am using SQL Server 2005 Integration Services to create new values for my tables. One step I must do is execute a query and the script task that receive its constraint (it is set to completion) must do different things depending on the query result.

My question is: how can I know the result of the precedence constraint?

Thank you,

Pablo Orte

If a task executes then it matched your precedence constraint. If you say "Complete" and "VarA == 20", and it executes then you can be assured that was the result. Are you wanting to do branching, or have multiple precedent constraints?|||

The key point to what I think Sean is suggesting, is that if you can get a variable to hold the result, you could use an expression to influence the constraint, whether it is satisfied or not. Expression support on a constraint is very useful for influencing workflow.

I am not sure that this is useful to you, since you have to populate that variable somehow. One way would be to use an on error event handler on the task. Default the variable to true, and change it to false in the event handler.

I don't know why or exactly what you are trying to do, but my first reaction would be this sounds like a bad idea. I think there should be a better, more SSIS way of trying to achieve this. Forgive me, but your method reminds me of the hacks we used in DTS. To conditionally do something why not use two tasks, or why not use event handlers to do an out of band type operation when something fails.

|||

This thread might have somthing for you...

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=859001&SiteID=1

Rafael Salas

|||

Hi and thanks for your replies,

The problem I have is that I have to do this in a script task situated after an "Execute SQL". This cannot return any parameter and I need to have something in the code like this

IF objDTSPackage.Steps("DTSStep_DTSExecuteSQLTask_1").ExecutionResult = 0 THEN

This code worked in SQL Server 2000, but not in SQL Server 2005.

Thanks,

Pablo Orte

Sunday, February 19, 2012

get parameter and use in SSIS from SSRS parameter

Hi,
I am not sure this is the correct place to post this question, but here it is. I am trying to pass some parameters to SSIS from a report using the report parameter, then SSIS will create the datareaderdest and return to the report to use.
Anyone have any idea, guidance or leads please share it out. Thanks in advance.
Daren

Not quite sure what you want to to do here. If you want to pass data from SSIS to SSRS then look here in BOL: ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/dtsref9/html/aba8ecb7-0dcf-40d0-a2a8-64da0da94b93.htm

-Jamie

|||Hi Jamie,
what I am trying to do is have a report that has two parameters, lets say param1 and param2. then when user enter the values lets say param1 = 1 and param2 = 5, these two parameters will be passed to SSIS and stored it in the variables I declared there.
do you know how to go about doing something like that? Thanks in advance.
Daren
|||

You can pass values via the command-line to a package when it executes, but those values will not be "stored" in the package so that they are there next time you execute.

-Jamie

|||Hi Jamie,
can you show me an example of how can I send through command-line or give me some guidelines on where I can find examples for them? Thanks in advance.
Daren
|||

Sure, look into the SET option of dtexec:

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlcmpt9/html/89edab2d-fb38-4e86-a61e-38621a214154.htm

-Jamie

|||Thanks Jamie,
I will try that out...
Daren
|||

Hi try using a syntax as follows:

= "/FILE D:\MyProject\\bin\dtsx\myDtsx.dtsx /SET \Package.Variables[var1];" + Chr(34) + Parameters!Var1.Value + Chr(34) + " /SET \Package.Variables[Var2];" + CStr(Parameters!Var2.Value) + " /SET \Package.Variables[Var3];" + CStr(Parameters!Var3.Value) + " /SET \Package.Variables[Var4];" + CStr(Parameters!Var4.Value)

If that works fine in VS environment and if it is giving an error once you deployed to ReportManager? Try specifying a TimeOut value for the SSIS DataSource connection within SSRS.

get parameter and use in SSIS from SSRS parameter

Hi,
I am not sure this is the correct place to post this question, but here it is. I am trying to pass some parameters to SSIS from a report using the report parameter, then SSIS will create the datareaderdest and return to the report to use.
Anyone have any idea, guidance or leads please share it out. Thanks in advance.
Daren

Not quite sure what you want to to do here. If you want to pass data from SSIS to SSRS then look here in BOL: ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/dtsref9/html/aba8ecb7-0dcf-40d0-a2a8-64da0da94b93.htm

-Jamie

|||Hi Jamie,
what I am trying to do is have a report that has two parameters, lets say param1 and param2. then when user enter the values lets say param1 = 1 and param2 = 5, these two parameters will be passed to SSIS and stored it in the variables I declared there.
do you know how to go about doing something like that? Thanks in advance.
Daren
|||

You can pass values via the command-line to a package when it executes, but those values will not be "stored" in the package so that they are there next time you execute.

-Jamie

|||Hi Jamie,
can you show me an example of how can I send through command-line or give me some guidelines on where I can find examples for them? Thanks in advance.
Daren
|||

Sure, look into the SET option of dtexec:

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlcmpt9/html/89edab2d-fb38-4e86-a61e-38621a214154.htm

-Jamie

|||Thanks Jamie,
I will try that out...
Daren
|||

Hi try using a syntax as follows:

= "/FILE D:\MyProject\\bin\dtsx\myDtsx.dtsx /SET \Package.Variables[var1];" + Chr(34) + Parameters!Var1.Value + Chr(34) + " /SET \Package.Variables[Var2];" + CStr(Parameters!Var2.Value) + " /SET \Package.Variables[Var3];" + CStr(Parameters!Var3.Value) + " /SET \Package.Variables[Var4];" + CStr(Parameters!Var4.Value)

If that works fine in VS environment and if it is giving an error once you deployed to ReportManager? Try specifying a TimeOut value for the SSIS DataSource connection within SSRS.