Is there any way to pass back an error message from a DTS when it is executed through a stored procedure ?
I have a DTS that is executed through a stored procedure.
If the DTS runs or fails, I get no indication of this unless I check that the DTS has done what it is suppose to have done.
The DTS imports , truncates and appends various tables and this is called using a stored procedure.
This is all ran from an Access front end and the stored procedure is called via a pass through query.
The code is :
....Declare various variables...
.....
-------------------Create Object----------------------------
EXEC @hr = sp_OACreate 'DTS.Package', @oPKG OUT
IF @hr <> 0
BEGIN
PRINT '*** Create Package object failed'
EXEC sp_displayoaerrorinfo @oPKG, @hr
RETURN
END
-------------------Set the Package--------------------------
EXEC @hr = sp_OAMethod @oPKG, 'LoadFromSqlServer', NULL, 'MyServer', @PackageName='MyDTSImport', @Flags=256
IF @hr <> 0
BEGIN
PRINT '*** Load Package failed'
EXEC sp_displayoaerrorinfo @oPKG, @hr
RETURN
END
----------------Execute the Package-------------------------EXEC @hr = sp_OASetProperty @oPKG
EXEC @hr = sp_OAMethod @oPKG, 'Execute'
---------------Destroy the Package--------------------------EXEC @hr = sp_OADestroy @oPKG
IF @hr <> 0
BEGIN
PRINT '*** Destroy Package failed'
EXEC sp_displayoaerrorinfo @oPKG, @hr
RETURN
END
GO
I have a DTS that is executed through a stored procedure.
If the DTS runs or fails, I get no indication of this unless I check that the DTS has done what it is suppose to have done.
The DTS imports , truncates and appends various tables and this is called using a stored procedure.
This is all ran from an Access front end and the stored procedure is called via a pass through query.
The code is :
....Declare various variables...
.....
-------------------Create Object----------------------------
EXEC @hr = sp_OACreate 'DTS.Package', @oPKG OUT
IF @hr <> 0
BEGIN
PRINT '*** Create Package object failed'
EXEC sp_displayoaerrorinfo @oPKG, @hr
RETURN
END
-------------------Set the Package--------------------------
EXEC @hr = sp_OAMethod @oPKG, 'LoadFromSqlServer', NULL, 'MyServer', @PackageName='MyDTSImport', @Flags=256
IF @hr <> 0
BEGIN
PRINT '*** Load Package failed'
EXEC sp_displayoaerrorinfo @oPKG, @hr
RETURN
END
----------------Execute the Package-------------------------EXEC @hr = sp_OASetProperty @oPKG
EXEC @hr = sp_OAMethod @oPKG, 'Execute'
---------------Destroy the Package--------------------------EXEC @hr = sp_OADestroy @oPKG
IF @hr <> 0
BEGIN
PRINT '*** Destroy Package failed'
EXEC sp_displayoaerrorinfo @oPKG, @hr
RETURN
END
GO