SSIS how to set connection string dynamically from a config file

后端 未结 5 483
南方客
南方客 2020-11-30 02:14

I am using SQL Server Integration Services (SSIS) in SQL Server Business Intelligent Development Studio.

I need to do a task that is as follows. I have to read from

5条回答
  •  春和景丽
    2020-11-30 02:56

    First add a variable to your SSIS package (Package Scope) - I used FileName, OleRootFilePath, OleProperties, OleProvider. The type for each variable is "string". Then I create a Configuration file (Select each variable - value) - populate the values in the configuration file - Eg: for OleProperties - Microsoft.ACE.OLEDB.12.0; for OleProperties - Excel 8.0;HDR=, OleRootFilePath - Your Excel file path, FileName - FileName

    In the Connection manager - I then set the Properties-> Expressions-> Connection string expression dynamically eg:

    "Provider=" + @[User::OleProvider] + "Data Source=" + @[User::OleRootFilePath]
    + @[User::FileName]  + ";Extended Properties=\"" + @[User::OleProperties] + "NO \""+";"
    

    This way once you set the variables values and change it in your configuration file - the connection string will change dynamically - this helps especially in moving from development to production environments.

提交回复
热议问题