Call DTS from Query Analyzer

Tech-Archive recommends: Speed Up your PC by fixing your registry



I'm trying to execute the following script from Query Analyzer. The
objective is to update the Global Variable in the DTS package. I'm not
getting any errors (@hr <> 0) yet the GV is not updating. I am a
sysadmin on the database.

DECLARE @hr int, @oPKG int, @name varchar(100)
SET @name = 'AL'

EXEC @hr = sp_OACreate 'DTS.Package', @oPKG OUT
EXEC @hr = sp_OAMethod @oPKG, 'LoadFromSQLServer',NULL, @@SERVERNAME,
@PackageName = 'WalkReport', @Flags = 256
EXEC @hr = sp_OASetProperty @oPKG,
'GlobalVariables("gv_Chapcode").Value', @name
EXEC @hr = sp_OAMethod @oPKG, 'Execute'
EXEC @hr = sp_OADestroy @oPKG

PS: Yes I've searched the groups but can't find out why mine would
fail.

Thanks,
Tim

.


Quantcast