Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use VBScript to check if DTS package exists??

Status
Not open for further replies.

jenkoller

Programmer
Feb 11, 2005
14
US
I have a VBScript that copies a DTS file to the SQL Server when doing an installation. How do I write the line that would check if this package exists alread in the SQL Server and if it exists deletes it and copies the new one?

Right now I have:

' VBScript source code
Const DTSSQLStgFlag_UseTrustedConnection = 256
Dim oPkg, oPkg2
set oPkg = CreateObject("DTS.Package2")
set oPkg2 = CreateObject("DTS.Package2")
oPkg.LoadFromStorageFile ".\UDR.dts", ""
oPkg.SaveToSQLServer "(local)", "", "", DTSSQLStgFlag_UseTrustedConnection
oPkg.UnInitialize
oPkg2.LoadFromStorageFile ".\UDR2.dts", ""
oPkg2.SaveToSQLServer "(local)", "", "", DTSSQLStgFlag_UseTrustedConnection
oPkg2.UnInitialize
Set oPkg = Nothing
Set oPkg2 = Nothing
 
Try insert this for inspection before deciding what to do.
[tt]
set cinfo=opkg.getsavedpackageinfo(".\udr.dts")
for each oinfo in cinfo
wscript.echo oinfo.packagename & vbtab & oinfo.versionid
next
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top