dbTalk Databases Forums  

Execute DTS from Stored Procedure

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Execute DTS from Stored Procedure in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Noel V. Meneses
 
Posts: n/a

Default Execute DTS from Stored Procedure - 10-15-2003 , 11:03 AM






I am developing a Data Process Package where I would
process data into a table using a stored procedure then
export it using DTS. Could I execute the DTS package from
a Stored Procedure? This way I would simplify the process
for the operators. I needed to process tha data in a
stored procedure so I could have the option to enter a
date range. I know I could execute DTS using a batch file
but this does not give me an option to prompt for a date
range.

Thanks,

Noel V. Meneses
Programmer
Contra Costa County Health Plan
595 Center Ave.
Martinez CA

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Execute DTS from Stored Procedure - 10-15-2003 , 02:19 PM






In article <014e01c39335$da050e20$a301280a (AT) phx (DOT) gbl>, Noel V. Meneses
<NMeneses (AT) hsd (DOT) co.contra-costa.ca.us> writes
Quote:
I am developing a Data Process Package where I would
process data into a table using a stored procedure then
export it using DTS. Could I execute the DTS package from
a Stored Procedure? This way I would simplify the process
for the operators. I needed to process tha data in a
stored procedure so I could have the option to enter a
date range. I know I could execute DTS using a batch file
but this does not give me an option to prompt for a date
range.

Thanks,

Noel V. Meneses
Programmer
Contra Costa County Health Plan
595 Center Ave.
Martinez CA
You could execute DTS from a batch file through DTSRUN, and use the /A
parameter to pass in your variables as global variables.

Or

Execute a package from T-SQL
(http://www.sqldts.com/default.aspx?210)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #3  
Old   
tony ordner
 
Posts: n/a

Default Re: Execute DTS from Stored Procedure - 10-15-2003 , 02:48 PM



I use this method as it seems cleaner to me... I found this on the web
sorry but I forgot who actually wrote it... I have working examples also if
you need.

thanks
tony o

Code follows:

Create procedure sp_DTS_Load_COSy_Stage --(@InConnection varchar (255))
as

set nocount on

declare @pkg int, @rc int

--Create an instance of a DTS package
exec @rc = sp_OACreate 'DTS.Package', @pkg output

--Load the baby up
exec @rc = sp_OAMethod @pkg
,'LoadFromSQLServer'
,null
,@Servername = "(local)"
,@Flags = 256 --NT authentication
,@PackageName = "COSy ODS - LOAD TXT TO COSy_STAGE"

--Set any properties of the package
--exec @rc = sp_OASetProperty @pkg
-- ,'GlobalVariables ("TextFileConnection").Value'
-- ,@InConnection

--do it
exec sp_OAMethod @pkg
,'Execute'

--destroy the instance
exec sp_OADestroy @pkg
Go

"Noel V. Meneses" <NMeneses (AT) hsd (DOT) co.contra-costa.ca.us> wrote

Quote:
I am developing a Data Process Package where I would
process data into a table using a stored procedure then
export it using DTS. Could I execute the DTS package from
a Stored Procedure? This way I would simplify the process
for the operators. I needed to process tha data in a
stored procedure so I could have the option to enter a
date range. I know I could execute DTS using a batch file
but this does not give me an option to prompt for a date
range.

Thanks,

Noel V. Meneses
Programmer
Contra Costa County Health Plan
595 Center Ave.
Martinez CA



Reply With Quote
  #4  
Old   
Noel Meneses
 
Posts: n/a

Default Re: Execute DTS from Stored Procedure - 10-16-2003 , 03:55 PM




Hi Tony,

I have some questions about the code you sent me.

--Create an instance of a DTS Package
exec @rc = sp_OACreate 'DTS.Package', @pkg output

Question: sp_OACreate - is this a stored procedure? If so I have no
idea what the source code is like.

Same questions for : sp_OAMethod, sp_OASetProperty & sp_OADestroy

Thanks for your help,

Sincereley

Noel


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #5  
Old   
Darren Green
 
Posts: n/a

Default Re: Execute DTS from Stored Procedure - 10-17-2003 , 02:20 AM



sp_OACreate is a stored procedure, or to be correct it is really an extended
stored procedure. You do not need to know the source as it already exists in
the master database, as supplied by MS. Just lookup sp_OACreate in the index
of SQL Server Books Online if you want to know more about it.


--
Darren Green
http://www.sqldts.com

"Noel Meneses" <nmeneses (AT) hsd (DOT) co.contra-costa.ca.us> wrote

Quote:
Hi Tony,

I have some questions about the code you sent me.

--Create an instance of a DTS Package
exec @rc = sp_OACreate 'DTS.Package', @pkg output

Question: sp_OACreate - is this a stored procedure? If so I have no
idea what the source code is like.

Same questions for : sp_OAMethod, sp_OASetProperty & sp_OADestroy

Thanks for your help,

Sincereley

Noel


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply With Quote
  #6  
Old   
Noel Meneses
 
Posts: n/a

Default Re: Execute DTS from Stored Procedure - 10-17-2003 , 11:25 AM




My problem now is having the permission to execute these extended stored
procedures. I searched in the Master database and it doesn't exist,
maybe I even don't have the right to view it. On SQL Server Books
Online it states that "Permissions: Only members of the sysadmin fixed
server role can execute sp_OACreate". Do I really need to have a
sysadmin fixed server role or is there any other way?

Thanks,

Noel

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #7  
Old   
Darren Green
 
Posts: n/a

Default Re: Execute DTS from Stored Procedure - 10-19-2003 , 10:00 AM



In article <u8p2AtMlDHA.3024 (AT) tk2msftngp13 (DOT) phx.gbl>, Noel Meneses
<nmeneses (AT) hsd (DOT) co.contra-costa.ca.us> writes
Quote:
My problem now is having the permission to execute these extended stored
procedures. I searched in the Master database and it doesn't exist,
maybe I even don't have the right to view it. On SQL Server Books
Online it states that "Permissions: Only members of the sysadmin fixed
server role can execute sp_OACreate". Do I really need to have a
sysadmin fixed server role or is there any other way?

Thanks,

Noel
You can grant execute rights on the sp_OA* procedures to other users,
but this isn't good practice. You could create a wrapper proc and only
grant permission on that instead.

A bit more info on the topic-

http://tinyurl.com/rhkp
--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.