SQL Server: Import DTS Packages using a Script

Use a VB Script file to import .DTS files into the local Sql Server database.

'determine current file location
Dim Path: Path=Left(WScript.ScriptFullName,Len(WScript.ScriptFullName)-Len(WScript.ScriptName)-1)
'.DTS files to be imported
Dim Sources: Sources = Array("File0.dts","File1.dts")

‘import each file
Dim i
For i = 0 To Ubound(Sources)
Import Path & “\” & Sources(i)

Sub Import(FilePath)

Dim P: Set P = CreateObject(“DTS.Package”)
With P
.LoadFromStorageFile FilePath, “”
‘import to local database, using a trusted connection
.SaveToSQLServer “(local)”, , ,256
End With

Set P = Nothing

End Sub

1 thought on “SQL Server: Import DTS Packages using a Script

  1. Subhash Subramanyam

    Hi craig,
    I have some interdependant *.DTS files which must not be renamed Like Array File List ( File01, File02..). In such case Would you please give me a complete code of how I can import all the dts files contained in a folder into local database.

    Many Thanks in advance for your needful help

Leave a Reply

Your email address will not be published. Required fields are marked *