Tuesday, September 17, 2013

SSIS: How to read SSIS Package properties without opening it?

Today I am sharing a small C# application that can be used to read the SSIS package properties. To see the properties of SSIS package such as Package name, no of connection managers, protection level, version number, GUID etc we generally have to open the SSIS package in design mode and check each of the properties.

With the help of this application we can read the properties of SSIS packages without opening them in design mode. The application interface is simple. You have to click on the browse button to select your SSIS package and then click on the button “Click to Read SSIS Package”. The list view control will show the properties name and their corresponding value.

The application code is following. You can customize this application further to read other properties of SSIS package.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.SqlServer.Dts.Runtime;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
            Package mySSISpkg = new Package();
            mySSISpkg = app.LoadPackage(textBox1.Text.ToString(),null);

            listView1.Clear();
            listView1.Columns.Add("Properties Name",150);
            listView1.Columns.Add("Value", 400);

            listView1.Items.Add(new ListViewItem(new string[] { "Package Name:", mySSISpkg.Name }));
            listView1.Items.Add(new ListViewItem(new string[] { "No of Connections Manager:", mySSISpkg.Connections.Count.ToString()}));
            listView1.Items.Add(new ListViewItem(new string[] { "Build No of package:", mySSISpkg.VersionBuild.ToString() }));
            listView1.Items.Add(new ListViewItem(new string[] { "Version No:", mySSISpkg.VersionMajor.ToString() + "." + mySSISpkg.VersionMinor.ToString() }));
            listView1.Items.Add(new ListViewItem(new string[] { "GUID:", mySSISpkg.VersionGUID.ToString() }));
            listView1.Items.Add(new ListViewItem(new string[] { "Protection Level:", mySSISpkg.ProtectionLevel.ToString() }));
           
        }

        private void button2_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            textBox1.Text= openFileDialog1.FileName.ToString();

        }

       
    }
}

The below picture show this application in action. I selected a package which was stored in my system and click on the appropriate button and it fetched me the properties of SSIS package.

This is useful in case you are dealing with large number of SSIS packages and has to open SSIS package frequently to check the settings and properties.

Popular Posts

Real Time Web Analytics