Thursday, 7 March 2019

Executing SSIS package using Excel Macros

There are multiple ways to run the SSIS package. In this demo, we will see how to run the SSIS package using Excel Macros.

You may have a question in your mind that we have n number of way to execute the SSIS package like SQL server agent, SP, bat file, command prompt, C#  or some other scheduler, then why we are using excel macro to execute a package.

Here I have a scenario:
I have developed a package. This package I used to read the data from an excel file and send the mail to the respective user. This package is used to run by the end user who does not have knowledge of SQL server or SSIS any other tool. Also, he is not export in comment prompt. In his machine, there is no SQL server agent.

In this case, we have limited scope to run the package. There are below option.
Ø  Execute the package using Excel Macro 
In this demo, we will see how to call the SSIS package using excel macro.
I am creating a simple package. This package I so simple, in this package I am inserting a record into a table.     
 
Inserting a table into this package
Now I am running this package
  
Package executed successfully.

See the record into the table
  
Now I am opening the excel file
 
     
And go the developer tab
OMG, I am not able to see the Developer tab.
Go to the File and select option
   

Click on Option
 
  

Select Customize Ribbon and select Developer and click OK.
Select the Developer tab
  

Click the insert and select Button and drag in the cell.
   

Now click on New button, A macro will be open.
 

Here we need to write the VB script.
Sub Button1_Click()
'Below Three Lines are used to run SSIS Package

'Declare Command as String
    Dim Command As String

'Set the value of Command, that includes dtexec and SSIS Package Location

    Command = "dtexec /f ""H:\Package.dtsx"""
'Run the Package

    Call Shell(Command, 0)
    MsgBox "Package is completed successfully"
End Sub
  
 
 
Now we need to save with Excel Macro-Enabled Workbook
    

Now macro is saved.
  

Open the file
Click the button.
Before executing the package see the records in the table.
  

Now running this package.
 

See the record in the table.

  
Hope this will be helpful!

8 comments:

  1. Hi,this is Very Nice information Regarding your Software Company and Beautiful Blog Also. So Np compete Also one of the Ios, Android, Java, Devops, UX, Ui, Chat Bot, Company in Chennai
    If you want any job Regarding above Positions,, Please give to Your Queries and send your Resume Back to this mail: sales@npcompete.com

    ReplyDelete
  2. Through this post, I know that your good knowledge in playing with all the pieces was very helpful. I notify that this is the first place where I find issues I've been searching for. You have a clever yet attractive way of writing on Msbi online training
    Msbi online training Hyderabad
    Msbi online training India
    Msbi online course
    Msbi course
    Msbi training
    Msbi certification training

    ReplyDelete
  3. Through this post, I know that your good knowledge in playing with all the pieces was very helpful. I notify that this is the first place where I find issues I've been searching for. You have a clever yet attractive way of writing on Msbi online training
    Msbi online training Hyderabad
    Msbi online training India
    Msbi online course
    Msbi course
    Msbi training
    Msbi certification training

    ReplyDelete
  4. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. CTFO

    ReplyDelete
  5. This is an exclusive post about PostgreSQL and the use of foreign data wrapper actually overcomes and helps people solve the most complex problems and errors.

    SSIS postgresql read

    ReplyDelete

If you have any doubt, please let me know.

Popular Posts