Hi everyone.
I've got a dts, which first drops/creates a set of tables, and then imports data into these tables from an access database.
Everything works fine if I run it manually from EM, however I want to script this out so have been trying to execute the package using t-sql automation objects...
here's the code:
when I run this, everything seems to be fine, and I don't get any error messages, however none of the import tasks have run because all my tables are empty.
The drop/create table tasks do run though because when I run this, data in the tables do all get cleared.
any ideas where I'm going wrong?
Thanks
--------------------
Procrastinate Now!
I've got a dts, which first drops/creates a set of tables, and then imports data into these tables from an access database.
Everything works fine if I run it manually from EM, however I want to script this out so have been trying to execute the package using t-sql automation objects...
here's the code:
Code:
DECLARE @HR INT, @PACKAGE INT
--create a ole object of type dts package
EXECUTE @HR = sp_OACreate 'DTS.Package', @PACKAGE OUT
IF @HR <> 0 BEGIN --check if package created successfully
RAISERROR('Failed to create DTS Package Object', 15, 1)
RETURN
END
--run the DTS package into the created object
--DTSSQLServerStorageFlags: DTSSQLStgFlag_Default = 0, DTSSQLStgFlag_UseTrustedConnection = 256
EXEC @HR = sp_OAMethod
@PACKAGE,
'LoadFromSQLServer',
NULL,
@ServerName='SEXPLT',
@PackageName='SOL_EX_IMPORT',
@Flags=256
IF @HR <> 0 BEGIN --check if package has been loaded correctly
RAISERROR('Failed to load DTS Package', 15, 1)
RETURN
END
--execute the package
EXEC @HR = sp_OAMethod @PACKAGE, 'Execute'
--cleaning up
EXEC @HR = sp_OADestroy @PACKAGE
IF @HR <> 0 BEGIN
RAISERROR('Failed to destroy DTS Package', 15, 1)
RETURN
END
GO
when I run this, everything seems to be fine, and I don't get any error messages, however none of the import tasks have run because all my tables are empty.
The drop/create table tasks do run though because when I run this, data in the tables do all get cleared.
any ideas where I'm going wrong?
Thanks
--------------------
Procrastinate Now!