View blogs by industry experts on topics such as SSAS, SSIS, SSRS, Power BI, Performance Tuning, Azure, Big Data and much more! You can also sign up to post your own business intelligence blog.
SQL Server Integration Services 2012 comes with a new API for scripting packages which is called MOM - Managed Object Model. In this article, I will demonstrate the scripting of Integration Services Catalog packages using C#.
We begin by launching Microsoft Visual Studio and create a new Integration Services Project which is located under Business Intelligence Projects category. After you have assigned a project name, proceed to click and drag the Script Task into Control Flow pane from toolbox. Right click the script task and click on “Edit” Under the Script Task Editor change the “ScriptLanguage” to “Microsoft Visual C# 2010". In Project Explorer, ensure the following references are added:
It is possible that you might not find the Microsoft.SqlServer.Management.IntegrationServices.dll under .NET references in visual studio, in which case I suggest you click here for an article on referencing the missing assembly file. Back to the code window, ensure that the following namespaces are declared:
Then under your main class create an instance of SMO Server as well as integration services object as shown below: The next part is to create an SSIS Catalog database followed by CatalogFolder, Project, then SSIS packages. It is possible, however, that you might have (or an administrator) created the SSIS Catalog. It is also possible that the CatalogFolder might have been created already. In order to address these possible scenarios, I have created a function with a set of parameters that can be called based on a particular scenario. The function is called:
Voilà! Now you can open SQL Server Management Studio and connect to the Server you provided in the above and you should find your newly created packages as shown below:
PS: This Article is cross-blogged from Sifiso's SSIS blog
Other posts by mafiswana