Executing SSIS Packages from command prompt / SSMS

“Dtexec” utility can be used to run the SSIS packages from the command prompt. Using dtexec utility you can load packages from a Microsoft SQL Server database, the SSIS service, and the file system.

The general syntax is

dtexec /option [value] [/option [value]]…

When a package runs, dtexec can return an exit code. Given below are the various exit values.

0 = execution successful

1 = package failed

3 = execution canceled

4 = the package could not be located

5 = unsuccessful in loading the package for execution

6 = error in the supplied command line

An example of “dtexec” is as given below

dtexec /f D:\Testing_Packs\testing_team\package3.dtsx
/SET \package.Variables[User::MyVariable].Properties[Value];VarValue1
/SET \package\DataFlowTask1.Variables[User::newVariable].Properties[Value]; VarValue2

You can execute the packages from SSMS and stored procs/functions using “XP_CMDSHELL” .Given below is an example

Exec xp_cmdshell ‘dtexec /f D:\Testing_Packs\testing_team\package3.dtsx
/SET \package.Variables[User::MyVariable].Properties[Value]; VarValue1
/SET \package\DataFlowTask1.Variables[User::newVariable].Properties[Value]; VarValue2 ‘

You might get an error while executing the above script , which might look like

Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1

SQL Server blocked access to procedure ‘sys.xp_cmdshell’ of component ‘xp_cmdshell’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘xp_cmdshell’ by using sp_configure.

This is because, as a security safeguard, Microsoft has turned off the use of xp_cmdshell by default . This has to be enabled by the users.

Follow the steps given to enable XP_CMDSHELL

1. Click the Start button.
2. Navigate to the Microsoft SQL Server 2005 folder.
3. On the flyout, mouseover Configuration Tools.
4. Select SQL Server Surface Area Configuration.
5. At the bottom of the window, select Surface Area Configuration for Features. You will get a window as in the image below.
6. In the left pane, under Database Engine, select xp_cmdshell.
7. Check the Enable xp_cmdshell checkbox.


8. Click OK.

Alternatively you can also configure XP_CMDSHELL through the proc SP_CONFIGURE.

Enable the ‘show advanced options’ then reconfigure to install it. Once this is done you will be able to enable XP_CMDSHELL. The code is as given.

EXEC sp_configure ‘show advanced options’ , 1
RECONFIGURE

EXEC sp_configure ‘xp_cmdshell’ , 1
RECONFIGURE

15 Comments

  1. “Executing SSIS Packages from command prompt / SSMS Awesome SQL” ended up being a beneficial
    blog. If only there were a lot more websites just like this
    particular one on the internet. Regardless, many thanks for your time, Blanca

  2. Hello just wanted to give you a quick heads up.
    The text in your content seem to be running off
    the screen in Internet explorer. I’m not sure if this is a format issue or something to do with web browser compatibility but I thought I’d post to let
    you know. The style and design look great though!
    Hope you get the issue fixed soon. Cheers

  3. I think everything posted made a great deal of sense.
    However, what about this? suppose you composed a catchier post title?

    I mean, I don’t want to tell you how to run your blog, however suppose you added a post title to possibly grab a person’s attention?

    I mean Executing SSIS Packages from command prompt / SSMS |
    Awesome SQL is kinda vanilla. You should look at Yahoo’s front page and note how they create post titles to grab people to open the links. You might add a related video or a related picture or two to grab people excited about what you’ve written.

    In my opinion, it would bring your posts a little bit more interesting.

  4. I think everything published made a bunch of sense. But, think on this, what if you wrote a catchier
    title? I mean, I don’t want to tell you how to run your blog, however suppose you added a title that makes people desire more? I mean Executing SSIS Packages from command prompt / SSMS | Awesome SQL is a little plain. You could look at Yahoo’s front page and see how they write post titles to grab viewers to click.
    You might add a video or a pic or two to grab readers
    interested about what you’ve got to say. Just my opinion, it would make your website a little bit more interesting.

  5. If you would like to increase your know-how just keep visiting
    this site and be updated with the most up-to-date news
    update posted here.

  6. An interesting discussion is worth comment.
    There’s no doubt that that you should publish more about this subject, it might not be a taboo matter but generally people don’t talk
    about such issues. To the next! Cheers!!

  7. Instead of printing the design on a paper, it will print on the t shirt.
    Till now Google installed different systems for tablets and smartphones.
    You can typically find these in home improvement stores and they’re not too expensive to buy.

  8. Real Racing 3, regarded among the teenagers as well as the multi purpose electronics
    devices bike race cheats that have spanned one or two programming languages.
    However, when you can to win all the guidelines discussed above in order to remain active from the
    basic brick based applications to pay a visit to play games on their cell
    phones. At the end, only two prominent examples are available for people.

  9. Although AMD Athlon processors aree manufactured to have lower heat production, cooling fans will help cool the processors more effectively especially if
    you plan to over-clock your CPU. By usong this AMD treatment three-pronged attack onn
    macular degeneration every day for sixx to twelve months patients are reporting improvements in their vision which
    was previously unheard of with this debilitating
    eye disease. too for a laptop oof this size and price but more of the price later.
    Yes there are bettsr options out there andd for some price does
    matter but when you aare with us, it doesn’t, because its always within your reach.
    6-inch ultra-extreme, thickness control in the range of values within 24.

Leave a comment