Question

How do i execute a DTS package automatically based on the updates in EXCEL file.

Asked by: newcom408

Hello Experts,

I have a DTS package which loads data from EXCEL to SQL Server table. It  needs to be executed automatically whenever there is a change in EXCEL file which is saved  in a  specific folder. Can anyone help me in doing this???

Since, I am new to DTS, if you could supply some examples would be greatly appreciated.

Thanks,

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-12-16 at 11:01:15ID21245233
Tags

dts

,

package

Topic

MS SQL Server

Participating Experts
2
Points
125
Comments
12

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. DTS package
    SQL server 2000, DTS package related: How can I generate or view the specs of the source text file to transform to database table? I am not using BCP format files.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: pra_kumar03Posted on 2004-12-16 at 11:24:52ID: 12844192

How about this
In the excel save or close event call a VB app or batch file which runs a job in the SQL Server. This job in turns calls the DTS job you created.

 

by: newcom408Posted on 2004-12-16 at 11:35:18ID: 12844297

sorry i couldn't get it. if you don't mind, Can you please explain me in detail. or provide some examples??

 

by: pra_kumar03Posted on 2004-12-16 at 11:55:36ID: 12844494

ok here is what needs to be done.

you must have a DTS task saved in the database.
create a bacth file. where you have the command to excute the DTS task using the dtsrun utility . the usage is attached in the last.
Then in the Excel you could record a macro to call the command shell and execute this batch file. The event in which you want to do that would be the Close event of the excel document.
 
to program the excel , go to Tools -> Macro ->Visual Basic Editor.
There you will see the workbook name. For the workbook there is a beforeclose event. You need to put code in it to run the batch file from the command shell
Shell("C:\batchfilename.bat")
this file of yours will have line like
dtsrun .........

+++++++++++++++++++++++++++++++++++++++++++++++++++++++
dtsrun Utility
The dtsrun utility executes a package created using Data Transformation Services (DTS). The DTS package can be stored in the Microsoft® SQL Server™ msdb database, a COM-structured storage file, or SQL Server Meta Data Services.

Syntax
dtsrun
[/?] |
[
    [
        /[~]S server_name[\instance_name]
        { {/[~]U user_name [/[~]P password]} | /E }
    ]
    {    
        {/[~]N package_name }
        | {/[~]G package_guid_string}
        | {/[~]V package_version_guid_string}
    }
    [/[~]M package_password]
    [/[~]F filename]
    [/[~]R repository_database_name]
    [/A global_variable_name:typeid=value]
    [/L log_file_name]
    [/W NT_event_log_completion_status]
    [/Z] [/!X] [/!D] [/!Y] [/!C]
]

Arguments/?

Displays the command prompt options.

~

Specifies that the parameter to follow is hexadecimal text representing the encrypted value of the parameter. Can be used with the /S, /U, /P, /N, /G, /V, /M, /F, and /R options. Using encrypted values increases the security of the command used to execute the DTS package because the server name, password, and so on, are not visible. Use /!Y to determine the encrypted command.

/S server_name[\instance_name]

Specifies the instance of SQL Server to connect to. Specify server_name to connect to the default instance of SQL Server on that server. Specify server_name\instance_name to connect to a named instance of SQL Server 2000 on that server.

/U user_name

Is a login ID used to connect to an instance of SQL Server.

/P password

Is a user-specified password used with a login ID.

/E

Specifies a trusted connection (password not required).

/N package_name

Is the name of a DTS package assigned when the package was created.

/G package_guid_string

Is the package ID assigned to the DTS package when it was created. The package ID is a GUID.

/V package_version_guid_string

Is the version ID assigned to the DTS package when it was first saved or executed. A new version ID is assigned to the DTS package each time it is modified. The version ID is a GUID.

/M package_password

Is an optional password assigned to the DTS package when it was created.

/F filename

Is the name of a structured storage file containing DTS packages. If server_name is also specified, the DTS package retrieved from SQL Server is executed and that package is added to the structured storage engine.

/R repository_database_name

Is the name of the repository database containing DTS packages. If no name is specified, the default database name is used.

/A global_variable_name:typeid=value

Specifies a package global variable, where typeid = type identifier for the data type of the global variable. The entire argument string can be quoted. This argument can be repeated to specify multiple global variables. See the Remarks section for the different available type identifiers available with global variables.

To set global variables with this command switch, you must have either Owner permission for the package or the package must have been saved without DTS password protection enabled. If you do not have Owner permission, you can specify global variables, but the values used will be those set in the package, not those specified with the /A command switch.

/L log_file_name:

Specifies the name of the package log file.

/W Windows_Event_Log

Specifies whether or not to write the completion status of the package execution to the Windows Application Log. Specify True or False.

/Z

Indicates that the command line for dtsrun is encrypted using SQL Server 2000 encryption.

/!X

Blocks execution of the selected DTS package. Use this command parameter when you want to create an encrypted command line without executing the DTS package.

/!D

Deletes the DTS package from an instance of SQL Server. The package is not executed. It is not possible to delete a specific DTS package from a structured storage file. The entire file needs to be overwritten using the /F and /S options.

/!Y

Displays the encrypted command used to execute the DTS package without executing it.

/!C

Copies the command used to execute the DTS package to the Microsoft Windows® clipboard. This option can also be used in conjunction with /!X and /!Y.


Remarks
If you do not specify any command line switches, specify an incorrect command line switch, or your command statement contains a syntax error, dtsrun returns error information and usage instructions. If you enter dtsrunui on the command line without any command line switches, you will start the DTS Run utility.

Spaces between command switches and values are optional. Embedded spaces in values must be embedded between double quotation marks.

If an option is specified multiple times, the last occurrence takes precedence. One exception is the /A command switch. Specifying more than one /A switch creates multiple global variables.

When specifying a global variable with the /A command switch, you must use a type identifier to indicate the data type of the global variable.

A tilde (~) character after the forward slash (for example, /~Z) indicates that the parameter value is encrypted and what follows is the hexadecimal text of the encrypted value.

The table shows the global variable data types and their IDs.


Data type Type ID
Integer (small) 2
Integer 3
Real (4-byte) 4
Real (8-byte) 5
Currency 6
Date 7
String 8
Boolean 11
Decimal 14
Integer (1-byte) 16
Unsigned int (1-byte) 17
Unsigned int (2-byte) 18
Unsigned int (4-byte) 19
Integer (8-byte) 20
Unsigned int (8-byte) 21
Int 22
Unsigned int 23
HRESULT 25
Pointer 26
LPSTR 30
LPWSTR 31


For information about where to find or how to run this utility, see Getting Started with Command Prompt Utilities.

Examples
To execute a DTS package saved as a COM-structured storage file, use:

dtsrun /Ffilename /Npackage_name /Mpackage_password

To execute a DTS package saved in the SQL Server msdb database, use:

dtsrun /Sserver_name /Uuser_nName /Ppassword /Npackage_name /Mpackage_password

To execute a DTS package saved in Meta Data Services, use:

dtsrun /Sserver_name /Uuser_nrame /Ppassword /Npackage_name /Mpackage_password /Rrepository_name

 

by: pra_kumar03Posted on 2004-12-16 at 11:59:12ID: 12844534

Also just take care to write a code that will save the file before calling the shell command

 

by: newcom408Posted on 2004-12-16 at 12:53:37ID: 12845025

somehow i couldn't see before close event in my work book.

 

by: pra_kumar03Posted on 2004-12-16 at 12:59:19ID: 12845091

Do you see any event in there?
else put his code

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.ActiveWorkbook.Save
Shell ("C:\batchfile.bat")
End Sub

 

by: pra_kumar03Posted on 2004-12-16 at 13:12:05ID: 12845189

oops...

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ActiveWorkbook.Save
Shell ("C:\batch.bat")
End Sub

 

by: newcom408Posted on 2004-12-16 at 13:15:36ID: 12845221

ok. now i am able to create this event in my work sheet.  where do i have to create this batchfile now??

 

 

by: pra_kumar03Posted on 2004-12-16 at 13:22:03ID: 12845278



Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim batchname as string
Application.ActiveWorkbook.Save

batchname = Application.ActiveWorkbook.path +"\"+"yourbatchfilename.bat"
shell(batchname)
End Sub


use the above place the batch file in the same path as your Excel file.
The batchfile will contain the dtsrun command in it
content of bacth file would be

dtsrun /Sserver_name /Uuser_nName /Ppassword /Npackage_name /Mpackage_password

 

by: newcom408Posted on 2004-12-16 at 13:28:18ID: 12845324

how to create this batchfile??

 

by: pra_kumar03Posted on 2004-12-16 at 13:31:56ID: 12845358

open a notepad
type the command i.e. dtsrun /Syourservername /Uusername /Ppassword /NyourpackageName /Mpassowrdfor package if any
Then click on File-> save As . In the save screen , type a file name like "dtsbatch.bat" and in the dropdown for file type select All files and then save it.

 

by: Syd2008Posted on 2007-12-06 at 11:25:52ID: 20422330

can anyone help me how to call a macro from a DTS package.
I have a Access database with a macro that runs the entire process now I have to automate the process so I have to create a DTS package and call this macro
please advice any help will appriciate

Thank you

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...