dbTalk Databases Forums  

Changing the SqlTask Via ActiveX

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


Discuss Changing the SqlTask Via ActiveX in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ron Sissons
 
Posts: n/a

Default Changing the SqlTask Via ActiveX - 04-27-2004 , 10:26 AM






Hi,
I have a dts package that has 23 ExecuteSqlTasks.
I know how to loop through each task. What I want to do
is change the Sql Statement. The problem is the sql script I have is about
800 lines long. How do I assign the script.sql file into a global variable
and then assign it to "oTask.customTask.SqlStatement = ".

Here is the code.

Dim oPackage
Dim oTask

set oPackage = DTSGlobalVariables.Parent

For Each oTask in oPackage.tasks
If oTask.CustomTaskID = "DTSExecuteSQLTask" then
msgbox oTask.Name
msgbox oTask.Description
oTask.customTask.SqlStatement =




End IF
Next

Main = DTSTaskExecResult_Success

Thanks


Ron Sissons, DBA
Information Technology Services
Riverside County Office of Education
3939 Thirteenth Street, Riverside, CA 92502-0868
Telephone: (909) 826-6471; FAX: [909] 826-6451


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Changing the SqlTask Via ActiveX - 04-27-2004 , 12:07 PM






Why not use an ExecuteProcess task and call osql instead and you can pass
the name of the file(s)

How to manipulate the Execute Process task.
(http://www.sqldts.com/default.aspx?251)

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Ron Sissons" <RSISSONS (AT) rcoe (DOT) k12.ca.us> wrote

Quote:
Hi,
I have a dts package that has 23 ExecuteSqlTasks.
I know how to loop through each task. What I want to do
is change the Sql Statement. The problem is the sql script I have is about
800 lines long. How do I assign the script.sql file into a global variable
and then assign it to "oTask.customTask.SqlStatement = ".

Here is the code.

Dim oPackage
Dim oTask

set oPackage = DTSGlobalVariables.Parent

For Each oTask in oPackage.tasks
If oTask.CustomTaskID = "DTSExecuteSQLTask" then
msgbox oTask.Name
msgbox oTask.Description
oTask.customTask.SqlStatement =




End IF
Next

Main = DTSTaskExecResult_Success

Thanks


Ron Sissons, DBA
Information Technology Services
Riverside County Office of Education
3939 Thirteenth Street, Riverside, CA 92502-0868
Telephone: (909) 826-6471; FAX: [909] 826-6451




Reply With Quote
  #3  
Old   
Ron Sissons
 
Posts: n/a

Default RE: Changing the SqlTask Via ActiveX - 04-27-2004 , 02:35 PM



Since I have the script execute on 23 different databases, I don't want to
create a SP. I want to be able to change the sql statement of the executesql
task by using a script.sql file. That way if I change the script, i can
update all the executesql tasks in my package.

SO my qwuestion is: how do I assing the file to a global variable and then
assign it to "oTask.customTask.SqlStatement = gv_sqlscript".



Ron Sissons, DBA
Information Technology Services
Riverside County Office of Education
3939 Thirteenth Street, Riverside, CA 92502-0868
Telephone: (909) 826-6471; FAX: [909] 826-6451


Quote:
K<anonymous (AT) discussions (DOT) microsoft.com> 4/27/2004 9:16:04 AM
Hello Ron;One other option would be to output the sql code to a text file
and have the text file assigned to the sql execute task. I am assuming using
you are using a lot of dynamic sql. Or else, you could probably just put the
800 line sql in a stored proc and call it from the execute sql task, no?hope
this helps,K ----- Ron Sissons wrote: ----- Hi, I
have a dts package that has 23 ExecuteSqlTasks. I know how to loop
through each task. What I want to do is change the Sql Statement. The
problem is the sql script I have is about 800 lines long. How do I
assign the script.sql file into a global variable and then assign it to
"oTask.customTask.SqlStatement = ". Here is the code. Dim
oPackage Dim oTask set oPackage = DTSGlobalVariables.Parent
For Each oTask in oPackage.tasks If oTask.CustomTaskID =
"DTSExecuteSQLTask" then msgbox oTask.Name msgbox
oTask.Description oTask.customTask.SqlStatement =
End IF Next Main = DTSTaskExecResult_Success
Thanks Ron Sissons, DBA Information Technology Services
Riverside County Office of Education 3939 Thirteenth Street, Riverside,
CA 92502-0868 Telephone: (909) 826-6471; FAX: [909] 826-6451




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

Default Re: Changing the SqlTask Via ActiveX - 04-27-2004 , 04:04 PM



In message <#$fOX7ILEHA.332 (AT) TK2MSFTNGP11 (DOT) phx.gbl>, Ron Sissons
<RSISSONS (AT) rcoe (DOT) k12.ca.us> writes
Quote:
Since I have the script execute on 23 different databases, I don't want to
create a SP. I want to be able to change the sql statement of the executesql
task by using a script.sql file. That way if I change the script, i can
update all the executesql tasks in my package.

SO my qwuestion is: how do I assing the file to a global variable and then
assign it to "oTask.customTask.SqlStatement = gv_sqlscript".


See my answer to your separate question on this, but the quick answer is
the Dynamic Properties Task.

--
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.