2. You could probably get at the DTS package via DMO. No example of this.
3. Use sp_OA sp's. Example of this is below (courtesy of Bill Hodghead)
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_displayoaerrorinfo]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_displayoaerrorinfo]
GO
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_displaypkgerrors]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_displaypkgerrors]
GO
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_executepackage]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_executepackage]
GO
create proc sp_displayoaerrorinfo
@object as int
as
Declare @hr int
DECLARE @output varchar(255)
DECLARE @source varchar(255)
DECLARE @description varchar(255)
PRINT 'OLE Automation Error Information'
EXEC @hr = sp_OAGetErrorInfo @object, @source OUT, @description OUT
IF @hr = 0
BEGIN
SELECT @output = ' Source: ' + @source
PRINT @output
SELECT @output = ' Description: ' + @description
PRINT @output
END
ELSE
BEGIN
PRINT ' sp_OAGetErrorInfo failed.'
RETURN
END
GO
create proc sp_displaypkgerrors
@pkg as int
as
declare @numsteps int
declare @steps int
declare @step int
declare @stepresult int
declare @pkgresult int
declare @hr int
select @pkgresult = 0
EXEC @hr = sp_OAGetProperty @pkg, 'Steps', @steps OUTPUT
IF @hr <> 0
BEGIN
print 'Unable to get steps'
EXEC sp_displayoaerrorinfo @pkg --, @hr
RETURN
END
EXEC @hr = sp_OAGetProperty @steps, 'Count', @numsteps OUTPUT
IF @hr <> 0
BEGIN
print 'Unable to get number of steps'
EXEC sp_displayoaerrorinfo @steps --, @hr
RETURN
END
while @numsteps > 0
Begin
EXEC @hr = sp_OAGetProperty @steps, 'Item', @step OUTPUT, @numsteps
IF @hr <> 0
BEGIN
print 'Unable to get step'
EXEC sp_displayoaerrorinfo @steps --, @hr
RETURN
END
EXEC @hr = sp_OAGetProperty @step, 'ExecutionResult', @stepresult OUTPUT
IF @hr <> 0
BEGIN
print 'Unable to get ExecutionResult'
EXEC sp_displayoaerrorinfo @step --, @hr
RETURN
END
if @intsecurity = 0
if @userpwd = Null
EXEC @hr = sp_OAMethod @object, 'LoadFromSqlServer',NULL, @ServerName=@svr, @ServerUserName=@login, @PackageName=@packagename, @Flags=@flag, @PackagePassword = @pkgPwd
-- ServerName As String, [ServerUserName As String], [ServerPassword As String], [Flags As DTSSQLServerStorageFlags = DTSSQLStgFlag_Default], [PackagePassword As String], [PackageGuid As String], [PackageVersionGuid As String], [PackageName As String], [pVarPersistStgOfHost])
else
EXEC @hr = sp_OAMethod @object, 'LoadFromSqlServer',NULL, @ServerName=@svr, @ServerUserName=@login, @PackageName=@packagename, @Flags=@flag, @PackagePassword = @pkgPwd, @ServerPassword = @userpwd
else
begin
select @flag = 256
EXEC @hr = sp_OAMethod @object, 'LoadFromSqlServer',NULL, @ServerName=@svr, @PackageName=@packagename, @Flags=@flag, @PackagePassword = @pkgPwd
end
IF @hr <> 0
BEGIN
print 'LoadFromSQLServer failed'
EXEC sp_displayoaerrorinfo @object --, @hr
RETURN
END
--execute it
EXEC @hr = sp_OAMethod @object, 'Execute'
IF @hr <> 0
BEGIN
print 'Execute failed'
EXEC sp_displayoaerrorinfo @object --, @hr
RETURN
END
--return the step errors as a recordset
exec sp_displaypkgerrors @object
-- unitialize the package
EXEC @hr = sp_OAMethod @object, 'UnInitialize'
IF @hr <> 0
BEGIN
print 'UnInitialize failed'
EXEC sp_displayoaerrorinfo @object --, @hr
RETURN
END
-- release the package object
EXEC @hr = sp_OADestroy @object
if @hr <> 0
Begin
EXEC sp_displayoaerrorinfo @object --, @hr
RETURN
end
GO
End of Article
I used the above language and received the error: LoadFromSQLServer failed OLE Automation Error Information Source: ODSOLE Extended Procedure Description: Bad variable type. Any ideas?
Tom July 26, 2001
You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor?
Register now
An often irreverent look at some of the week's other news, including a shortened work week thanks to the 4th of July, expensive Windows 7 pricing, Bing's modest monthly gains, IE 8 heading to work, Steve Jobs back at Apple, and so much more ...
Get Mark Minasi’s Windows Server 2008 Audio CDs "Windows expert, consultant and best-selling author Mark Minasi shows you if 2008 is right for you and, if so, how to get the most out of it!
Take Control of Your Email Optimize your email storage – Download this white paper to learn key how-to’s in email storage management.
Get Windows IT Pro To Go! The Windows IT Pro Magazine Master CD is a powerful combination of content and convenience. Order now, and save up to 25%--plus you’ll get online access to new articles each and every month! Subscribe today!
LoadFromSQLServer failed
OLE Automation Error Information
Source: ODSOLE Extended Procedure
Description: Bad variable type.
Any ideas?
Tom July 26, 2001