Import .DTS file into an SQL 2000 server

  • I made changes to an Production DTS and need to import that dts file into prod system now with the same name. I tried to save it from the DEV system (where i made the modifications) using "Save As" and then choosing the Prod sql server. But it failed that the pkg already exists with different Id.

    So, i saved it as a .dts file and tried to import into the prod. It also failed with the same error. How should I resolve this?

  • Have you tried dropping the existing package first?

    -- Gianluca Sartori

  • Deleting the existing packages is not at all an option. Because they have several versions of the package which they would revert back if there are any issues with the new version

  • I'm afraid there's not much you can do.

    However, I would save previous versions of the package to a source control system, rather than relying on SQL Server versioning.

    The only option I can think of is writing a VBScript to:

    1) Load the source package from DEV (you get a handle to the latest version)

    2) Load the destination package from PROD (you get a handle to the latest version)

    3) Empty the destination package

    4) Copy all objects from the source package to the destination package

    5) Save the destination package

    Somebody already tried this method:

    http://us.generation-nt.com/answer/savetosqlserver-package-id-problems-help-53899742.html#r

    What can I say?... Good luck!

    -- Gianluca Sartori

  • take a look at this routine:

    http://www.nigelrivett.net/DTS/s_LoadPackageToServer.html

    It worked for me... πŸ™‚

  • In SQL Server 2000, if you have a requirement to copy/transfer multiple DTS packages from one instance to the other, doing it manually becomes cumbersome. There are utilities in the market that do that for you but what if you have to make this import a part of your install? If you have such a requirement, then you can save your DTS packages as files and then write up a simple VB Script and call it through cscript to load up the packages. You can put this process into your install shield code to give a better end user experience.

    /******************************************************************************/

    β€˜ Usage: cscript ImportPackages.vbs <sql server name> <sql server userid> <sql server password>

    β€˜

    β€˜ Example: cscript ImportPackages.vbs microndt2978-2 sa password

    And here is the code for the ImportPackages.vbs (we use this in the case of slot_info in order to load the DTS packages):

    option explicit

    β€˜β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”-

    β€˜ ImportPackages.vbs β€” import DTS packages from .dts files.

    β€˜

    β€˜ Usage: cscript ImportPackages.vbs <sql server name> <sql server userid> <sql server password>

    β€˜

    β€˜ Example: cscript ImportPackages.vbs microndt2978-2 sa password

    β€˜

    β€˜ This script imports all packages from the folder specified below to the

    β€˜ specified SQL Server.

    β€˜

    β€˜β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”-

    const PACKAGE_FOLDER = β€œDTS Packages”

    dim oPackage

    dim oFile

    dim sPath

    dim iCount

    dim sPackageName

    dim sServer

    dim sUserid

    dim sPassword

    dim oArgs

    β€˜ Validate arguments.

    set oArgs = wscript.Arguments

    if oArgs.count < 3 then

    wscript.echo β€œUsage: cscript ImportPackages.vbs <sql server name> <sql server userid> <sql server password>”

    wscript.quit 1

    end if

    sServer = oArgs(0)

    sUserid = oArgs(1)

    sPassword = oArgs(2)

    β€˜ Obtain the path that the script is run in. The DTS package folder

    β€˜ is relative to that path.

    sPath = left(wscript.scriptfullname, len(wscript.scriptfullname) – len(wscript.scriptname))

    dim fso

    set fso = CreateObject(β€œScripting.FileSystemObject”)

    dim oFolder

    β€˜ Make sure the package folder exists.

    if not fso.FolderExists(sPath & PACKAGE_FOLDER) then

    wscript.echo β€œCan’t find package folder ” & sPath & PACKAGE_FOLDER

    wscript.quit 1

    end if

    set oFolder = fso.GetFolder(sPath & PACKAGE_FOLDER)

    iCount = 0

    β€˜ Iterate through the package files.

    for each oFile in oFolder.Files

    wscript.echo β€œImporting ” & oFile.Path

    set oPackage = CreateObject(β€œDTS.Package2?)

    β€˜ Get the package name, which is the name of the .dts file

    β€˜ without the .dts extension.

    sPackageName = left(oFile.Name, len(oFile.Name) – 4)

    β€˜ Delete the package, but don’t error out if it already doesn’t exist.

    on error resume next

    oPackage.RemoveFromSQLServer sServer, sUserid, sPassword, , , , sPackageName

    on error goto 0

    β€˜ Load the package from the .dts file.

    oPackage.LoadFromStorageFile oFile.Path, β€œβ€

    β€˜ Save the package to SQL Server.

    oPackage.SaveToSQLServer sServer, sUserid, sPassword

    iCount = iCount + 1

    β€˜ Release the package object. It can’t be reused.

    set oPackage = Nothing

    next

    wscript.echo β€œSuccessfully imported ” & iCount & ” packages.”

    wscript.quit 0

    -----------------------------------------------------------------------------------------

    Kaarthouders

    Stoepborden

    Folderbakjes

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply