Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a DTS from query analyser

Status
Not open for further replies.

Erics44

Programmer
Oct 7, 2004
133
GB
Hi
How do I run a DTS from query analyser?
Thanks
 
I would imagine that you can use the dtsrun utility, if you hit F1 and type 'dtsrun utility' into your help option then it tells you all about it.
 
Save your DTS pacakege in location as Structured Storage File.
Then call that file using the below syntax.

[tt]
/*--------Export Out any Error Lines to A File --------------------*/
DECLARE @object int
DECLARE @hr int

--create a package object
EXEC @hr = sp_OACreate 'DTS.Package', @object OUTPUT
if @hr <> 0
BEGIN
print 'error create DTS.Package'
RETURN
END

EXEC @hr = sp_OAMethod @object, 'LoadFromStorageFile',
NULL, '\\SERVERNAME\DTS\DTS_Package_Name.dts', '' -- Production File
IF @hr <> 0
BEGIN
print 'error LoadFromStorageFile'
RETURN
END

EXEC @hr = sp_OAMethod @object, 'Execute'
IF @hr <> 0
BEGIN
print 'Execute failed'
RETURN
END
[/tt]
--destroy the instance of the DTS
exec sp_OADestroy @object


Dr.Sql
Good Luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top