Welcome to blogs.conchango.com Sign in | Join | Help

Welcome to blogs.conchango.com

SSIS Junkie

SSIS: Passing parameters on the command line to an SSIS package

One of the nice features about the dtsrun command that came with DTS2000 was the ability to populate a package global variable from the command line. i.e.:

dtsrun /S MyServer /E /N MyPackage /A MyGlobalVar:8=

The replacement for dtsrun in SSIS, DTExec, has a similar mechanism. It uses the /Set switch. In fact, its better than dtsrun because it can be used to set any property of an executable or a variable as opposed to just a variable value. To look at it another way, you can basically do stuff on the command line that you used to have to do using a Dynamic Properties task.

The syntax of the /Set switch is /set propertypath;value

propertyPath is, unsurprisingly, the path to a property in the package. It has its own syntax. The path must start with "\Package". Backslash notation is used to navigate through the package object hierarchy to an object, and thereafter dot notation is used to access a property of that object.

For example, to change the 'Disable' property of a data flow called 'MyDataFlow' that is in a Foreach loop container called 'MyForeachLoop' the /set switch would look like this:

  • /set \Package\MyForEachLoop\MyDataFlow.Disable;False

An easy way of viewing the property path of a property is to create an XML configuration file for the package referencing the property in question. The resultant .dtsconfig file will contain the property path.

Lastly, a further utility called DTExecUI is provided that will build the command line string for you in exactly the same way that dtsrunui did for DTS2000.

As ever...I'd welcome some feedback!!!

- Jamie

 

 

Published 13 December 2004 22:59 by jamie.thomson

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

jamie.thomson said:

If you could add some screen shots to what you have explained, I believe that might help understand this much faster
My 2 Cents:-)
May 18, 2005 03:01
 

jamie.thomson said:

Hi PP,

What would you like screenshots on exactly? A screenshot of an MS-DOS window wouldn't be very thrilling. How about DTExecUI?

-Jamie
May 18, 2005 14:39
 

Vincenzo said:

Can I send a parameter via web, from a web page to an SSIS package ???
October 3, 2005 16:51
 

jamie.thomson said:

Vincenzo,
You can call a SSIS package from .net so you could build an ASP.net app that allows you to do this.

-Jamie
October 3, 2005 17:32
 

evan (ny) said:

My package is a little more complex in that I use namespaces and I can't seem to get the syntax right. Basically, I have a global var called db_servername in namespace ConnStr.. Here's my cmd-line (and output ).

----------------------------------

H:\Visual Studio 2005\Projects\Feed Processing IS>dtexec /FILE "H:\Visual Studio 2005\Projects\

Feed Processing IS\Packages\Import_JPM.dtsx" /SET \Package\Import_JPM.ConnStr::db_server;"local

host"

Microsoft (R) SQL Server Execute Package Utility

Version 9.00.1399.06 for 32-bit

Copyright (C) Microsoft Corp 1984-2005. All rights reserved.

Started:  6:23:15 PM

Warning: 2007-03-12 18:23:16.22

  Code: 0x80012017

  Source: Import_JPM

  Description: The package path referenced an object that cannot be found: "\Package\Import_JP

M.ConnStr::db_server". This occurs when an attempt is made to resolve a package path to an obje

ct that cannot be found.

End Warning

DTExec: Could not set \Package\Import_JPM.ConnStr::db_server value to localhost.

----------------------------

Help pls! Thanks.

March 12, 2007 22:27
 

evan (ny) said:

The cmd-line should read:

dtexec /FILE "H:\Visual Studio 2005\Projects\Feed Processing IS\Packages\Import_JPM.dtsx" /SET \Package\Import_JPM.ConnStr::db_servername;"localhost"

but I get the same result ...

March 12, 2007 22:28
 

jamie.thomson said:

Evan,

You've got the syntax of the property path wrong. It should be:

\Package.Variables[ConnStr::db_servername].Properties[Value]

I'm pretty sure there is documentation on the package path syntax. Did you find it? If you don't want to build package paths yourself just copy them from the configurations dialog.

Could you direct your queries to the SSIS forum? That way people with similar problems in the future will be able to find the answer (hopefully).

-Jamie

March 13, 2007 00:34
 

SSIS Junkie said:

A comment here from Evan made me realise that there doesn't really exist a good reference for property

March 13, 2007 01:06
 

jamie.thomson said:

March 13, 2007 01:07
 

evan (ny) said:

Jamie,

Thanks for the info! Your syntax worked just fine.

With respect to proper forum, can you provide link to the forum???

I will post future requests/comments there ...

Thanks again!

March 13, 2007 12:48
 

Gabriela said:

Can i change the query of the pkg? with dtexec and "set"

August 30, 2007 18:31
 

jamie.thomson said:

Gabriela,

Yes, I don't see why not.

-Jamie

August 30, 2007 18:36
 

Gabriela said:

But i dont know how,  can i send a var to the query? plis help me i dont know how

August 30, 2007 18:38
 

kral oyun said:

September 13, 2007 18:50
 

callmelee said:

Jamie,

What about passing multiple parameters to the package? I can get it to work with one Set statement, but not sure of the syntax when multiple variables need to be set.  Can you point me in the right direction?

Thanks!

October 26, 2007 17:41
 

jamie.thomson said:

Hi callmelee,

Using multiple /SET options should work.

-Jamie

October 26, 2007 17:57
 

Mel said:

Jamie,

What takes precedence, the command line value you assign a variable or the value you enter for it in a config file (if you have it in a config file as well)... The idea is to have a configurable default value for a variable but still be able to force the package to run with another value, would that work?

Thanks

Mel.

November 8, 2007 15:59
 

jamie.thomson said:

Mel,

Ahh...you got me. I honestly don't know off the top of my head. Could you give it a go and let me know?

I would hope that the value supplied from the command-line would "win".

Thanks

Jamie

November 9, 2007 00:58
 

Shoaib Danish said:

I am using the following command

/set "\Package\DataFlowTask.Variables[User::Name].Properties[Value]";"MYName"

But I am having following error

  Description: The package path referenced an object that cannot be found: "\Pa

ckage\DataFlowTask.Variables[User::Name].Properties[Value]". This occurs when an

attempt is made to resolve a package path to an object that cannot be found.

End Warning

DTExec: Could not set \Package\DataFlowTask.Variables[User::Name].Properties[Val

ue] value to MYName.

November 9, 2007 11:58
 

Shoaib Danish said:

I got the solution, there was a syntax problem. But I check this with MSDN and according to that I was right. :-(.

November 9, 2007 12:06
 

Mel said:

Refering to a couple of posts ago, the command-line value supplied for a property when executing an SSIS package overrides the value in the config file if both are supplied.

So it works as thought...

Mel.

November 14, 2007 20:28
 

izlesene said:

thanks.

December 6, 2007 06:47
 

evden eve nakliyat said:

Thanka

February 16, 2008 23:00
 

evden eve nakliyat said:

very good site..

February 16, 2008 23:00
 

Colin Macguire said:

Hi Jamie,

Thanks for the great blog. I did a fair bit of research before I stumbled upon this blog, so I managed to get the SSIS package to run via T-SQL without any issues.

The thing that I cannot get done is to use variables from within T-SQL as the values that are assigned to the SSIS package variable when the dtexec command is run (If this makes any sense).

A simple example of what I want done can be seen in the code posted below:

----------------------------------------------------------

DECLARE @Var_Run_Date DATETIME

SET @Var_Run_Date = '2007/12/10 0:00:00 AM'

EXEC

xp_cmdshell

'dtexec /FILE "D:\Work\Data_Warehouse\Sample_Dimension.dtsx" /SET \Package.Variables[User::Var_Batch_Date].Value;"@Var_Run_Date"'

----------------------------------------------------------

This works perfectly if I manually set the value for the package variable, however it does not if I use the variable listed above.

Any suggestions?

Kind Regards,

Colin Macguire

April 2, 2008 09:21
 

jamie.thomson said:

Hi Colin,

Hmmm...not sure about this one. Have you thought about building the whole xp_cmdshell... command as a string and then passing it to sp_executesql?

-Jamie

April 2, 2008 13:35
 

David Lathrop said:

Try the following:

DECLARE @CMD VARCHAR(8000)

SET @CMD = 'dtexec /FILE "D:\Work\Data_Warehouse\Sample_Dimension.dtsx" /SET \Package.Variables[User::Var_Batch_Date].Value;"'

+ CONVERT( VARCHAR(25), @Var_Run_Date, 101)

xp_cmdshell @CMD

--------------------------

SQL Server has to evaluate the @Var_Run_Date into a date and make it part of the (single) string sent to the Windows command shell. The way you are coding it, the text "@Var_Run_Date" is supposed to get assigned. (Also, check the style argument to the CONVERT function for proper format.)

April 3, 2008 22:13
 

Shaas said:

I could not believe that the SET statement is case sensitive.

Cheers.

April 9, 2008 22:13
 

Shaw said:

I am kinda new to SSIS. Done work with DTS 2000. In SSIS 2005, I have a package whose first task is to take data from csv file and import in to sql. The format of the CSV remains same, but file name keeps on changing. How can I set the `File Name` parameter in the `Flat File Connection Manager Editor` window from command line?

Your comments and suggestions will help!

April 24, 2008 17:45
 

jamie.thomson said:

Hi Shaw,

The answer is here:

Property Paths Syntax

http://blogs.conchango.com/jamiethomson/archive/2007/03/13/SSIS_3A00_-Property-Paths-syntax.aspx

let me know on that thread if you have any questions.

-Jamie

April 25, 2008 10:28
 

oyun oyna said:

May 3, 2008 10:34
 

SSIS Junkie said:

In the past I have advocated (and still do advocate) the use of a user variable in SSIS packages to store

May 19, 2008 12:22
 

Clive Richardson said:

I have an SSIS package called with dtexec and I'm passing variables on the command line.  All fine so far.  However, I want to add a /SET for a data flow task property... It's the BulkInsertTableName property for the 'SQL Server Destination' task.   Note that this property isn't exposed via Variables in Expressions.  I wasn't sure but was certainly hopeful that I could cheat by passing the property in via dtexec.   Can I do this?  If so, how do I find the correct path?  

eg. /SET "\Package\SQL Server Destination.BulkInsertTableName.value";"myTable"

Jeepers... I wonder why MS can't make basic properties like this accessible more easily?

Cheers,

Clive

July 2, 2008 17:26
 

jamie.thomson said:

Clive,

If that property is exposed as a property of the dataflow (explained here: http://blogs.conchango.com/jamiethomson/archive/2007/10/09/SSIS_3A00_-Dataflow-expressions.aspx) then you can do it.

Can you suggest a syntax that would be easier?

-Jamie

July 2, 2008 17:32
 

Clive Richardson said:

Jamie,

It's not exposed.  I wondered if it was possible to set it on the command line anyway?

I'm not sure I understand your question about syntax.   I don't mind what the syntax is as long as I can get it to work.

Clive

July 3, 2008 09:33
 

jamie.thomson said:

Clive,

I've just taken a look. It is exposed. Admittedly I'm looking at SQL Server 2008 so can't confirm that the same is true in SQL Server 2005 but I fully expect that it is.

How did you determine that it isn't exposed? Go to the Control Flow, select the dataflow that contains your SQL Server Destination, hit F4 to bring up the properties pane. You should see a property in there called [<destination-name>].[BulkInsertTableName]

-Jamie

July 3, 2008 09:50
 

oyunlar said:

very nice page thanks

July 16, 2008 10:13
 

oyun said:

It's not exposed.  I wondered if it was possible to set it on the command line anyway?

I'm not sure I understand your question about syntax.  

July 16, 2008 10:14
 

jamie.thomson said:

Oyun,

What are you referring to? What uestion about syntax? Have you previously posted here using a different name?

-Jamie

July 16, 2008 10:17
 

sesli said:

In the past I have advocated (and still do advocate) the use of a user variable in SSIS packages to store

July 24, 2008 22:23
 

oyunlar said:

thanks blogs.conchango.........

August 5, 2008 12:17
 

molla said:

thankss

August 28, 2008 07:17
 

coco said:

thanks blogs.conchango.........

August 28, 2008 07:18
 

james.pegg said:

i have a dtsrun bat file with a line that looks like this:

DTSRUN /S GANDALF /E /N GeneralDSSmith /A CSVPath:8=c:\dataextract\General.csv /A UDLPath:8=c:\dataextract\DBConnection.udl /A DatabaseObject:8=DSSmithCW."dbo"."pstGeneral"> c:\dataextract\DtsRun\General.LOG

could you convert this to dtexec format as i am struggling to understand the new syntax.

November 12, 2008 12:07
 

james.pegg said:

anyone?

November 14, 2008 13:44
 

jamie.thomson said:

James,

My dtsrun knowledge is patchy at best. UDLs don't exist in SSIS either. The blog post above tells you the nearest equivalent for the /A option. What else do you want to know?

Bottom line is three is no magic formula for converting dtsrun syntax to dtexec syntax because the two are not analogous.

-Jamie

November 14, 2008 14:04
 

reklam said:

thank you very good

November 21, 2008 18:10
 

Consulta SSIS | hilpers said:

February 16, 2009 19:02

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

Powered by Community Server (Personal Edition), by Telligent Systems