SQL SERVER – Running SSIS Package in Scheduled Job

I previously wrote article SQL SERVER – Import CSV File into Database Table Using SSIS. I was asked following question by reader that how to run the same SSIS package from command prompt. In response to the same I have written article SQL SERVER – Running SSIS Package From Command Line. Within few minutes of the blog post, I received email from another blog reader asking if this can be scheduled in SQL Server Agent Job.

Absolutely, SSIS package can be scheduled in SQL Agent Jobs. Here is quick note on how one can do the same.

First you can create new job from SQL Server Agent Menu.

SQL SERVER - Running SSIS Package in Scheduled Job packagerun1

Create New Step.

SQL SERVER - Running SSIS Package in Scheduled Job packagerun2

Select Type as SQL Server Integration Services Packages. Select Package Source as file system and give package path.

SQL SERVER - Running SSIS Package in Scheduled Job packagerun3

Now click on OK, which will bring you at following screen.

SQL SERVER - Running SSIS Package in Scheduled Job packagerun4

On next screen you can select schedule and configure desired schedule.

SQL SERVER - Running SSIS Package in Scheduled Job packagerun5

SQL SERVER - Running SSIS Package in Scheduled Job packagerun6

You can notice this is very easy process. Let me know if you have any further questions.

Reference : Pinal Dave (https://blog.sqlauthority.com)

SQL Scripts, SQL Server, SQL Utility
Previous Post
SQL SERVER – Download PowerPivot Security Architecture Diagram
Next Post
SQL SERVER – What is SQL Azure

Related Posts

109 Comments. Leave new

  • any one solve this problem in sql server 2005 , automatic backup not done… kindly consider my request asap.

    Reply
  • i have created the job but when i tried to execute it i had an error regarding some logon error.

    Logon failure: unknown user name or bad password. The step failed

    please help me

    Reply
  • hi all…i’m trying to execute the ssis i’ve created using bids (visual studio 2010). the package runs without problem when executed manually in bids..however when i followed above steps error is encountered…please help.
    thanks in advance.

    Reply
  • i have also same problem as reggie. after creating schedule package is executed with errors. please help me.

    Reply
  • Himanshu Batavia
    October 30, 2012 3:20 pm

    Hi Pinal,

    Thank you for your article. I had also developed Job in the same way you had created. But it doesn’t execute automatically. I have to right click on Job name and have to execute it by clicking on Start Job as Step. What should I do to execute it automatically? From someone I got idea of SSIS package, but it asks for .dtsx file and I don’t know how to create .dtsx file. I go through the internet on following urt. It has so many steps that I cannot create SSIS package. Please guide me and please give me reply on [email removed]

    Thanks
    Himanshu

    Reply
  • Please consider the following scenarios and questions.
    Scenario 1:
    I run an SSIS package from a SQL Agent job. While the SSIS package is executing, I stop the SQL Agent job.
    Does the SSIS Package continue to run?

    Scenario 2:
    I have an SSIS Package that retrieves data from a SQL Server instance on one of our remote office servers. The system uses this SSIS Package to retrieve data from several offices, so the specific instance configuration parameters are stored in a configuration database.
    Does SSIS 2008 permit concurrent instances of an SSIS package?
    Thanks for all of the great information you publish on this site. I visit regularly, and I always find your articles to be well written and useful.

    Reply
  • Hi,
    I tried Scheduling the SSIS package. But the job fails with the following error in the logs.

    Log in Failed for the User. Reason: Password did not match that to the log in provided.

    I gave the right user id and password. Please Help !!!!!!!!!

    Reply
  • I have a question regarding SSIS packages,
    say I have a SSIS package
    and many packages excutes the package aforementioned as “Excute package task”.
    Is there any way to get a list of all “excuting tasks” that excute ?

    is there any query I can use to attain this information?
    thanks

    Reply
  • I was able to import data from a particular excel into DB via SQL Server Agent job scheduler, perfectly.

    But, now I came to know that.. the user will daily pull out an Excel Report ( perhaps with same Name+current-date as the file name) and drop that into the shared folder. Now the SQLServer Agent Scheduler ought to pick the latest excel and kindly append the data into the particular table of the database.
    My problem is while creating the SSIS package in wizard I will necessarily be giving one particular excel name in the DataSource. Any solution that you can suggest?

    Reply
  • Naseer Farooqi
    January 17, 2013 2:54 am

    Hi Himanta,

    Use this routine
    How to add dates dynamically to a text file with SSIS
    Sometimes it’s important to create text files and label them with a date at the end. Or you import text files and they contain dates in them. In DTS you would use global variables, and then dynamic properties to do this. However that has all changed in SSIS. There are no more dynamic variables properties in SSIS.

    Case Example: You have a sales report which you send off to a client on a daily basis. In order for the client to know which file is for what day, he/she wishes that you label the text files with the date in the file name.

    Example :Rpt_Product_Sales_yyyymmdd.csv so it can be something like Rpt_Product_Sales_20070107.csv

    1) You must first create a variable. You need to declare it as a string. Here I created a variable called ‘path’ and declared it a string data type.
    This is the place where you want to enter the path \\server1\file\location\Rpt_Product_Sales_

    2) Set up your Data Flow in the Control Flow. In this example, I will be taking data from my DB and dumping it into a text file.

    3) Next you will want to right click on your flat file connection and goto properties. After that on the properties box, you will need to locate ‘Expressions’ and hit the box to the right of it.

    4) When you have click on the box to the right of ‘Expressions’ in the properties of the Flat file connection, you should get the screen below.

    5) You will want to select ‘ConnectionString’ from the property side.

    6) After that, you need to click on the box that is to the right of ‘ConnectionString’, under ‘Expressions’. The expression builder box will show up. Here is where you will do the scripting to add dates in the file name.

    First find the variable which you created in step 1. Drag that into the Expression builder workspace. That’s the path and the file name which we created in the Flat File Connection Manager. After you dragged the variable down, you can hit ‘Evaluate Expression’ and it will show you the path and name. In our example it’s c:\Rpt_Product_Sales_

    Here is where we add the code.

    @[User::path] +
    (DT_STR,4,1252) DatePart(“yyyy”,getdate()) +
    Right(“0” + (DT_STR,4,1252) DatePart(“m”,getdate()),2) +
    Right(“0” + (DT_STR,4,1252) DatePart(“d”,getdate()),2) + “.csv”

    This is what I entered into the work space. I wanted the file name to be Rpt_Product_Sales_yyyymmdd.csv. The above accomplishes the task. You will notice that I’m padding the left side of Month and Day with a leading ‘0’ (zero) then using Right function to take 2 characters. I’m also using the DatePart function as well to get the year, month, and day from the getdate() function.

    Enter the info and then click on ‘Evaluate Expression’ and if you have done it correctly you will have your dynamic file name with a date.

    Hit okay and debug your SSIS package.

    If you have any questions, feel free to contact me via email [email removed]

    Reply
    • Here are more exmplanations

      Reply
      • Hi I followed the same steps which u have mentioned above and it works perfectly fine. after generating these files.. I want to show these generated file names in email which is sent once the files are copied to the FTP location. Please let me know how can i show the file names in my send email task body.

  • Hi, I have data with data type decimal (6,2) in my database. I would like to have output in flat file to be like 2.00 + space with the remaining length. For example, the data is 2.00 and I want the output looks like “2.00 ” (the length is 7 char). Anyone has suggestion on this? Thanks for your kind help.

    Reply
  • Hi Pinal ,

    Thanks … But i have a question …. How to create a SQL server agent job ? From where we need to create a new job ?

    one more requirement for me …

    I need to create a new folder in my personal location dynamically every new month . is that possible from SSIS

    Kindly help

    Reply
    • Hi Athrey,

      To create a SQL server agent job you need to have the access of SQL server agent and if it stopped then do right click on SQL server agent and run its services.
      When you expand the SQL Server agent then there is an option of JOB do right click on that and create a new job. You will see there are so many types of SQL server agent job in your case you need to choose SQL Server integration services from the drop down menu of SQL job types.

      And if you want to create a new folder in your personal location you have to choose file system task in SSIS package and operation should be create directory in that and configure it with the Folder name and the location of that. When you will ready with SSIS create a new SQL server agent job which will run your .dtsx and schedule it to run 1st day of every month.

      If you want then I can give you sample code for SSIS and SQL server agent job to achieve your goal.

      Reply
  • Roohi Sachdeva
    February 5, 2013 8:12 am

    I have got dialogue box added to SSIS package,through script at the end,that populates when process is completed.

    But it throws the below error when called from SSMS job “Script Task: Error: Exception has been thrown by the target of an invocation”

    Script has just below code is in C#

    System.Windows.Forms.MessageBox.Show(“Process has completed”);

    Please clarify.

    Reply
  • Hello Pinal,

    There is service account where we are using in 25-30 servers, is there any package / tool update the service account at one shot instead of updating each server?

    [email]

    Reply
  • I have a sql job which calls a wcf service (ssis web service task). The sql job step times out after 5 minutes and the job terminates with an error, but the service takes over an hour to complete. Is there any way to keep the sql job running until the service completes?

    Reply
    • Hi Crelp,

      You can set the retry attempt value in SQL agent job, when you will define it then SQL job will run itself after a period of time and yes you can also define the end time for that so that finally SQL job stop to retry itself…

      Reply
  • Excellent instructions. It worked for me. Thanks!

    Reply
  • Hi,
    Do we any option to run a scheduler without using SQL agent Job, We dont that features enable in sql server 2008 R2.

    Reply
  • Hi Pinel

    pls tell me what the required permissions to edit the SSIS package configurations in SQL Server agent, when it configured in below manner

    Package Source : SQL Server
    Server : SQL Instance Name.

    I am facing the issue. I have given the permissions to a windows user as
    below.

    Mapped to msdb database and gave .

    ssisadmin
    ssisltduser
    ssisoperator
    sqlagentoperatorrole
    sqlagentreaderrole
    sqlagentuserrole

    I am using SQL Server 2008 R2 enterprise.

    but still user is unable to edit the package.

    the options are grayed out.

    I need to give permissions to edit the package with out giving sysadmin permissions.

    Please help me to fix.

    Reply
    • Hi Kranthi..

      You are unable to edit SSIS package configuration or SSIS package?
      Please let me know this I may help you.

      Reply
    • Hi Kranthi,

      You want to change in SSIS package configuration file or in SSIS package? Please let me know thia I may help you.

      Reply
  • thank u thank u very much sir..

    Reply
  • Hello Sir,

    All your post are really too helpful.

    Reply

Leave a Reply