Solved

ssis - execute stored procedure

Posted on 2010-09-20
5
1,085 Views
Last Modified: 2013-11-10
I am trying to figure out how to execute a stored procedure from ssis. I have a working stored procedure. It has no parameters. I want to somehow execute it fro an ssis package. I found something at another site that says: Another option is to use expressions in the execute sql task editor.  You could create an expression for the SqlStatementSource property.  A simple example:"exec usp_SomeProc @somevar = '"+ @[User::strSomeVar]+"'"
but I could not figure out how to do that. I just want a simple EXEC dbo.usp_MAINTAIN_UDF_HISTORY.
0
Comment
Question by:qbjgqbjg
5 Comments
 
LVL 16

Expert Comment

by:vdr1620
Comment Utility
Try using

"
SET FMTONLY ON
SET NOCOUNT ON

exec usp_SomeProc @somevar = '"+ @[User::strSomeVar]+"'"
0
 

Author Comment

by:qbjgqbjg
Comment Utility
I was already using SET NOCOUNT ON. Actually I think I may have it figured out. I used execute sql task . And the trick was for the sql command, I had to spell out execute. So the command was
EXECUTE dbo.usp_MAINTAIN_UDF_HISTORY. It worked. Now I am trying to figure out how to make it send me an email if it fails.
0
 
LVL 30

Accepted Solution

by:
Reza Rad earned 250 total points
Comment Utility
if this is a data flow task, with ole db source,
set data access mode as "SQL Command"
and in sql command text, write like this:
exec mySP

instead of mySP write your stored procedure name,

if your stored procedure has any parameters you should use question mark as each of parameters. but if there is no parameter, just user exec mySP.


0
 
LVL 15

Assisted Solution

by:AmmarR
AmmarR earned 250 total points
Comment Utility
Dear qbjgqbjg:

just use a simple Execute SQL Task and type in exec SP_name and it should work fine

check image below, i am using it to call a store procedure and its working fine.
exec-SP.png
0
 

Author Comment

by:qbjgqbjg
Comment Utility
I had already tried it with EXEC  dbo.usp_MAINTAIN_UDF_HISTORY in the execute sql task. It did not work. It produced an error.  EXECUTE dbo.usp_MAINTAIN_UDF_HISTORY does work.
We are using sql server 2005. So maybe there is a difference.
execute-stored-procedure.docx
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now