I have setup a stored procedure to allow me to run any DTS package from Query Analyzer. When I run the stored procedure for a DTS package that moves data from one SQL DB to another it works. However, when I run the stored procedure for packages which transer data from MS Access to SQL, it does not work. Specifically, the log file for the package indicates the step failed and the run time is instantaneous. Also, the log file for the step is not created. If I run this same package from within Enterprise Manager everything works as expected. Also, the Access DBs live on a different computer.
I'm running SQL Server 7.
Any ideas?
The stored procedure is listed below:
CREATE Procedure usp_RunDTSPackage @PkgName as varchar(50)
AS
Declare @hr int
declare @oPkg int
--Create the DTS package object
exec @hr=sp_OACREATE 'DTS.Package', @oPKG OUT
If @hr<>0
Begin
Print '*** Create package object failed - ' + @PkgName
Return
End
--Load the package
Exec @hr=sp_oamethod @oPkg,'LoadFromSqlServer',Null, @ServerName='PMA2', @PackageName=@PkgName, @Flags=256
If @Hr<>0
Begin
Print '*** Load package failed - ' + @PkgName
Return
End
--Execute the package
Exec @hr=sp_oamethod @oPkg, 'Execute'
If @Hr<>0
Begin
Print '*** Execute failed - ' + @PkgName
Return
End
--Cleanup
Exec @hr = sp_oadestroy @oPkg
If @Hr<>0
Begin
Print '*** Destroy package failed - ' + @PkgName
Return
End
Thanks in advance,
Michael
I'm running SQL Server 7.
Any ideas?
The stored procedure is listed below:
CREATE Procedure usp_RunDTSPackage @PkgName as varchar(50)
AS
Declare @hr int
declare @oPkg int
--Create the DTS package object
exec @hr=sp_OACREATE 'DTS.Package', @oPKG OUT
If @hr<>0
Begin
Print '*** Create package object failed - ' + @PkgName
Return
End
--Load the package
Exec @hr=sp_oamethod @oPkg,'LoadFromSqlServer',Null, @ServerName='PMA2', @PackageName=@PkgName, @Flags=256
If @Hr<>0
Begin
Print '*** Load package failed - ' + @PkgName
Return
End
--Execute the package
Exec @hr=sp_oamethod @oPkg, 'Execute'
If @Hr<>0
Begin
Print '*** Execute failed - ' + @PkgName
Return
End
--Cleanup
Exec @hr = sp_oadestroy @oPkg
If @Hr<>0
Begin
Print '*** Destroy package failed - ' + @PkgName
Return
End
Thanks in advance,
Michael