Thursday, 19 September 2013

Package Configuration in SSIS with SQL Server Configuration.

SSIS is completely replacement of DTS and it becomes first class SQL Server components along with database engine, analysis services, and reporting services. It is a good practice if you keep configuration value not in SSIS but outside SSIS packages. Those configuration values could be saved on XML configuration file, environment variable, windows registry, parent package variable or SQL Server. The use of XML configuration file is not uncommon now but it is less secure compared to save it into windows registry or environment variable. But it is rigid implementation if the option is to use windows registry or environment variable. The balance between security and flexibility is to save it into SQL Server.
 
This posting will guide you how to implement package configuration into SQL Server.
 
  1. Open your visual studio. Choose File menu > New > Project.
  2. In New Project dialog box, look at Project Types left pane, and choose item : Business Intelligence Projects.
  3. In Templates list box, choose Integration Services Project.
  4. In Name text box, fill out your SSIS project name and click OK button.
  5. Now you focus on Package.dtsx or if it is not opened yet, you double click on it at Solution Explorer window pane.
  6. Create package level variable, so go to SSIS menu > Variables.
  7. In Variables window pane, click New toolbar to create new SSIS variable. You can edit the variable name for example I name it myVar. Then change the variable data type to String. The variable value I would bind it with SSIS configuration with SQL Server type repository.
  8. Click blank area in the SSIS package or Control Flow designer window.
  9. Go to SSIS menu > Package Configurations…
  10. In Package Configuration Organizer window, tick check box “Enable package configurations”
  11. Click Add button
  12. In Package Configuration Wizard, click Next button
  13. You will be presented with Select Configuration Type section, choose SQL Server in Configuration Type combo box.
  14. Make sure you choose “Specify Configuration settings directly”, click New button beside Connection combo box.
  15. In Configure OLE DB Connection Manager window, choose New button.
  16. Type your database server name, database name, and click “Test Connection” button to test whether you can connect to database server. If test is successful, click OK button to close Connection Manager window and go back to Configure OLE DB Connection Manager. And click OK to go back to Package Configuration Wizard window.
  17. Click New button beside Configuration Table combo box. And click OK button. The wizard will create SSIS configuration table.
  18. Type your Configuration Filter, for example Configuration.VariableA and click Next button.
  19. In “Select Properties to Export” section, from Objects list box, go to the variable that is created on step 7, expand its properties and tick Value property.
  20. Click Next button to go to “Completing the Wizard” section, name your configuration name, for example MyConfiguration and click Finish button to go back to Package Configurations Organizer window.
  21. click Close button.
  22. by default myVar variable value is still empty, you need to fill it from “SSIS Configuration” table, so open SSMS (SQL Server Management Studio) and open the table.
  23. After you open “SSIS Configuration” table, go to Configuration.VariableA and type any value in ConfiguredValue column then commit the change.
  24. go back to BIDS, still you find the SSIS variable value is empty, you need to refresh it by close the package designer window and reopen it.
  25. Now you will find the variable value is filled with value from SQL Server configuration repository.