Visual BasicThis Visual Basic example assumes you have add a reference to your project to the "Microsoft DTSPackage Object Library", located in "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\dtspkg.dll", when using SQL Server 2000. When using SQL Server 7.0 the file is located in "C:\MSSQL7\BINN\dtspkg.dll" if you installed SQL Server in the default installation directory.Option ExplicitPublic Sub main() Dim oPkg As DTS.Package2
Set oPkg = New DTS.Package2
oPkg.LoadFromSQLServer "(local)\dev", , , _
DTSSQLStgFlag_UseTrustedConnection, , , , _
"PackageExecutionWithParams"
oPkg.Execute
oPkg.UnInitialize
Set oPkg = NothingEnd Sub
Set oPkg = New DTS.Package2
oPkg.LoadFromSQLServer "(local)\dev", , , _
DTSSQLStgFlag_UseTrustedConnection, , , , _
"PackageExecutionWithParams"
oPkg.Execute
oPkg.UnInitialize
Set oPkg = NothingEnd Sub
xp_cmdshell 'dtsrun ...'呵呵