Cogniza | Business-Intelligence Specialists

Nov/06

16

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)
Next

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 comment

  • Subhash Subramanyam · February 27, 2007 at 11:52 am

    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

 

<<

>>

Theme Design by devolux.nh2.me