Link to home
Start Free TrialLog in
Avatar of cheek1e
cheek1e

asked on

SQLServer 7 DTS calling from proc

So I have a DTS package which works fine from Enterprise Manager. I am trying to call from a stored proc. It all seems to execute ok (no return errors) but the package is not executing.

All permissions and file locations are fine. I've stripped the proc code down to this and running in QueryAnalyser which is also not executing...

DECLARE @errDesc VARCHAR(1000)

exec master.dbo.sp_OACreate 'DTS.Package', @objPackage OUTPUT
exec master.dbo.sp_OAMethod @objPackage, 'LoadFromSQLServer' , null, @ServerName = 'VME44WS45', @Flags = 256, @PackageName = 'DTS__PLclosesIn'
exec master.dbo.sp_OAMethod @objPackage, 'Execute'
exec master.dbo.sp_OAMethod @objPackage, 'Uninitialize'
exec master.dbo.sp_OADestroy @objPackage

Any ideas?
Thanks,
S

Avatar of cherrypie
cherrypie

HI

try putting your loadfromsqlserver command into a string first with all the required variables and then executing it - this always works for me

eg:

declare @cmd varchar(500), @objPackage int
SET @Cmd = 'LoadFromSQLServer("VME44WS45", "", "", 256, "", , , "DTS__PLclosesIn")'
exec master.dbo.sp_OACreate 'DTS.Package', @objPackage OUTPUT
exec master.dbo.sp_OAMethod @objPackage, @Cmd, NULL
exec master.dbo.sp_OAMethod @objPackage, 'Execute'

enjoy
This is kind of a lousy method of doing it.

Why don't you just use XP_CMDSHELL and DTSRUN to execute the package????
Avatar of cheek1e

ASKER

I need to call a different package depending on parameters sent to the stored proc.
Can I still do this with xp_cmdshell?

Avatar of cheek1e

ASKER

OK I can execute the DTS with xp_cmdshell but am getting an error:

Error string:  Error opening datafile: Access is denied.

I'm in QueryAnalyser logged in as sa (as would be in EM - where the file is accessed), and running the command with /E

Nearly there!


Avatar of cheek1e

ASKER

All sorted now.

Had to change the SQL server startup account.
ASKER CERTIFIED SOLUTION
Avatar of arbert
arbert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cheek1e

ASKER

yep it works gloriously now :-)

i guess this thread should be closed...
yep....