July 28, 2008 at 4:07 am
Hi,
I have requirement in SSIS packages. I need to store multiple connection string in one config file with different names. Let SQLDev, SQLStg and SQLProd. User will pass a value to my ssis package like SQLDev or SQLStg or SQLProd.
How do i pick connection string from config file based on user input? If user passes SQLDev then i should pick the respective connection string.
Please help me....
July 28, 2008 at 4:19 am
You could store each connection string in its own variable (SQLDev, SQLProd, etc). Have a variable to hold the user's choice of environment (SetEnv, maybe). Then, have a separate variable to hold the connection string you wish to use.
So, call the new variable something generic like SQLMain, set this to be evaluated as expression and use the expression builder to set the connection string based on the value of the SetEnv variable.
Alternatively, hold the connection strings in a central config database along with an environment identifier. So, have a column for variable name (SQLConn) and a column for environment (Dev, Prod, etc). Hold the connection to this config database in one config file.
Then, on runtime, pass in the environment code, pull out the necessary variables for that environment from the db, and use a script task to populate the variables with their new values. This solution allows greater flexibility and removes hardcoded business logic from the package.
Hope this helps,
Tom
July 28, 2008 at 5:28 am
Thanks a lot for the immediate response. I am not sure how to implement this logic. I am new to SSIS Packages. Please see my code below and correct me
1. I have declared 5 variables SQLMain, SQLDev, SQLStg, SQLProd and SetEnv in my package
2. i have variables in my config file
3. i am executing my Package like this.
Declare @cmd varchar(1000)
Select @cmd = 'dtexec.exe /f "C:\SSISPackages\Package.dtsx" /Set \Package.Variables[User::SetEnv].Value;SQLDev'
exec master..xp_cmdshell @cmd
What do you mean by "set this to be evaluated as expression and use the expression builder to set the connection string based on the value of the SetEnv variable."? How do we do this? I am not sure how to do this.
July 28, 2008 at 5:46 am
If you look at the properties of the SQLMain variable, you will see a property called EvaluateAsExpression. Set this to True.
Then, right below this, there is a property called Expression. Click in here, and then click on the ellipses button to open up the expression builder. Within here you can specify the logic to set the connection string you wish to use.
Something like:
UPPER(@[User::SetEnv]) == "PROD" ? @[User::SQLProd] : UPPER(@[User::SetEnv]) == "STG" ? @[User::SQLStg] : @[User::SQLDev]
(This will default to the DEV connection string).
This will solve your current problem in the short term, but you may want to consider a central config solution to manage variable values for the longer term.
Tom
July 28, 2008 at 6:52 am
Thanks a lot. It helped me a lot. I am accessing SQLMain variable inside Script task and updating connection string value of connection manager.
How do we use same config file across packages?
Do we need to alwasy specify config file path while executing package(using dtexec.exe)?
July 28, 2008 at 7:51 am
July 29, 2008 at 9:45 am
Hi,
I am getting another error while executing SSIS Package in SQL Server.
Declare @cmd varchar(1000)
set @cmd = 'dtexec.exe /f "E:\SSISPackages\SSISDeploy\ExportData.dtsx" /Set \Package.Variables[SourceDB].Value;AS400DEV /Set \Package.Variables[DestinationDB].Value;SQLDEV /CONF "C:\SSISDeploy\Environment.dtsConfig"'
exec master..xp_cmdshell @cmd
The error is below
The configuration file name "... development system path where config file is available .." is not valid. Check the configuration file name.
My package is not picking config file which i specified in command prompt. It was looking in my local system.
Surya
July 29, 2008 at 9:53 am
the config file needs to be where the packages can see it, either locally in the same location on each box that runs the package (remember that the package runs on the machine that calls it, not on the machine on which it is stored), or on a network share to which the package has access.
July 30, 2008 at 4:02 am
I am getting the below error while executing my package from SQL Server 2005. Actually i am importing data from AS400 to SQL. Do i need to configure anything in SQL before i executed the script?
When i execute the same package from File system, it was working fine.
In Config file, I have specified connection string as mentioned below
Execution script:
Declare @cmd varchar(1000)
set @cmd = 'dtexec.exe /f "E:\SSISPackages\SSISDeploy\ExportData.dtsx" /Set \Package.Variables[SourceDB].Value;AS400DEV /Set \Package.Variables[DestinationDB].Value;SQLDev /CONF "E:\SSISPackages\SSISDeploy\Environment.dtsConfig"'
exec master..xp_cmdshell @cmd
Error is ...
Description: System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.Odbc.OdbcConnection.Open()
at Microsoft.SqlServer.Dts.Runtime.ManagedHelper.GetManagedConnection(String assemblyQualifiedName, String connStr, Object transaction)
at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManager90.AcquireConnection(Object pTransaction)
at Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter.AcquireConnections(Object transaction)
at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostAcquireConnections(IDTSManagedComponentWrapper90 wrapper, Object transaction)
Please help me
July 30, 2008 at 4:05 am
i think i missed the connection string for as400
Driver={Client Access ODBC Driver (32-bit)};System=AS400DEV;Uid=myUserID;Pwd=myPassword;
July 9, 2009 at 3:55 am
Hi,
I am trying to run SSIS package using DTEXEC command. While executing the config file is not picked up. Could you please let me know what was the issue here. I am getting the below warning message.
Cannot load the XML configuration file. The XML configuration file may be malformed or not valid.
"C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\DTExec.exe" /DTS \MSDB_IMIDEV\Hiearchy_Master /SER Server /CONFIGFILE "\\100.100.xxx.xxx\imi-lz-prd\DNTs\HMSTR_Config.dtsconfig" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /REPORTING V /CONSOLELOG NCOSGXMT
July 9, 2009 at 3:56 am
Hi,
I am trying to run SSIS package using DTEXEC command. While executing the config file is not picked up. Could you please let me know what was the issue here. I am getting the below warning message.
Cannot load the XML configuration file. The XML configuration file may be malformed or not valid.
"C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\DTExec.exe" /DTS \MSDB_IMIDEV\Hiearchy_Master /SER Server /CONFIGFILE "\\100.100.xxx.xxx\imi-lz-prd\DNTs\HMSTR_Config.dtsconfig" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /REPORTING V /CONSOLELOG NCOSGXMT
July 9, 2009 at 3:56 am
Hi,
I am trying to run SSIS package using DTEXEC command. While executing the config file is not picked up. Could you please let me know what was the issue here. I am getting the below warning message.
Cannot load the XML configuration file. The XML configuration file may be malformed or not valid.
"C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\DTExec.exe" /DTS \MSDB_IMIDEV\Hiearchy_Master /SER Server /CONFIGFILE "\\100.100.xxx.xxx\imi-lz-prd\DNTs\HMSTR_Config.dtsconfig" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /REPORTING V /CONSOLELOG NCOSGXMT
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply