Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
|
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 8th, 2004, 08:41 AM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 2
Thanked 0 Times in 0 Posts
Default Calling DTS package from VBA

        I am new at working with SQL Server DTS and executing it from VBA. I am having difficulty getting a DTS package (that works perfectly from Enterprise Manager - DTS Designer) to complete its process when I call it from VBA.

    My saved DTS package in SQL Server DTS Designer performs the following steps.

    1) Drop the table
    2) Create the table with Prime Key
    3) Create a UNIQUE NONCLUSTERED index on "<Field_UNIQ>"
    4) Imports data from a .CSV flat file
    5) Updates several other fields



    The package works great from Enterprise Manager. The only thing that doesn't completely execute is Step 4 (above) because the data I am importing has duplicates in my field <Field_UNIQ>. However, looking at the result set, it appears that it did what I wanted because it imports the non-duplicate records.

Note: I don't want to import records that have non-unique values in <Field_UNIQ>. While it would be nice to get some feedback as to how many records were skipped, it is not critical at this point.

QUESTIONS:

    1) Is another there way to call the saved "server"
           DTS packages from VB? (I have not been able
           to execute 'dtsrun' from a stored proc; see below)?

    2) Is there a way to re-work the import step
           in DTS Designer so that the process won't
           abort the entire process when it finds its first duplicate value in <Field_UNIQ> (see below)?

           (It doesn't do this from DTS Designer;
           only when I call it from my "dtsExecutePackage"
           script on the client. Note: I am trying to
           keep the client thin)

        3) Is there another way to do this and keep my client thin?

--------------------------------------
HERE IS WHAT I TRIED:

    I tried using "master xp_cmdshell 'dtsrun parameters>'" from a Stored Procedure. (This is not the exact syntax and unfortunately I don't have the code here) The error message kept saying that I didn't have permissions. I tried calling it with the option that says to use Windows permissions / authentication. I tried then to call it with user = "sa". I kept getting the same error.

    I had my SQL Server "guru" buddy (who has since left the company) work with me on getting "dtsrun" to work, but neither of us could do it. We suspect that the non-resident DBA has security set so that we can't use it. Because I am a sub-contractor onsite with the customer, getting them to change security settings won't work.
    My next observation was that I could save my saved DTS Designer package as a .sql script file, however, I could never find a way to launch a .sql script from inside SQL Server or the client. I suspect that .sql files are only for transporting or archiving server objects, or for saving queries from Query Analyzer.

     Next, I saved the DTS package to a file as a VB Script (.bas file) and incorporated the code into my project. I linked my VBA project into the .DLL that supports this. The process works fine, but I was surprised at the amount of code require on the client. This runs counter to my keeping the client thin, so I kept looking.

    The next thing I tried was saving the DTS package as a .dts file on the server and using a "dtsExecutePackage" example that I found in the SQL Online Books. I got it to run, but it would not import any records. The feedback I got from the example's error handler was cryptic, but indicated that it aborted in mid-task. I finally figured out that the process is stopping on Step 4 (Import data). It is getting to record 2 or 3, finding a duplicate <Field_UNIQ> value, and aborting the entire routine without committing any records. This doesn't happen when I execute my saved package from DTS Designer.

    In Step 3 (Create a UNIQUE NONCLUSTERED index on <Field_UNIQ> ), I used the option "IGNORE_DUPES" (I think that is the way it is spelled ... I copied and pasted it from Help) which the help file says will allow INSERTS on ALL records that do not have duplicate values in that field. It appears to work fine from DTS Designer, but the .dts file I saved, when called from VBA still aborted the entire import process.

The End
------------------

Thank you ahead of time for any suggestions or examples you can provide! :)


--- Tom
__________________
--- Tom
 
Old October 8th, 2004, 10:39 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

you may find your answer here

http://www.sqldts.com/default.aspx?208

Jaime E. Maccou
Applications Analyst
 
Old October 13th, 2004, 10:05 PM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Thanks, jemacc! That helped!


--- Tom





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with DTS PACKAGE mxwebb SQL Server DTS 1 November 28th, 2007 05:16 PM
Calling an SP from a DTS Package? Gibi SQL Server DTS 1 April 18th, 2007 05:47 AM
question on DTS package kpshende SQL Server 2000 0 April 22nd, 2006 07:08 AM
Calling a DTS Package from VB levinll Pro VB Databases 0 November 7th, 2005 04:09 PM
DTS Package Deployment acdsky VB Databases Basics 1 February 22nd, 2004 12:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.