Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

get storedproc return value in dts

Posted on 2006-07-24
5
Medium Priority
?
260 Views
Last Modified: 2008-03-10
Hi,

I have a stored proc which has an update statement. There are 3 cases, it either does the update(n rows), it doesn't do any update(0 rows) or it fails. If it fails I can use the fail task to send myself email and if it succeeds I can send email as well. However, if it doesn't run at all i.e. 0 rows updated then it's neither success nor failure. I would like to know how i can find out if it did not run or didnt do any changes so that I can send email accordingly.

Please advise.

Thanks
0
Comment
Question by:Devsql
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 300 total points
ID: 17170576
Here's one way.  I imagine this will vary greatly by developer.

CREATE PROCEDURE YourProc(@success bit) AS

UPDATE YourTable
SET Column1 = Value1

IF @@ROWCOUNT > 0
   begin
   -- Your Update statement updated at least one record.
   @success =1
  end
else
  begin
  -- Your Update statement did not return any records.  
  @success=0
  end

SELECT @success
GO
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17170868
You cannot return an output parameter to DTS (at least not directly) You will have to resort to returning a resultset containing the variable, as suggested in the previous comment, make sure to alias it.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17171111
Some small modifications to Jim's code (no points please):

CREATE PROCEDURE YourProc()

AS

SET NOCOUNT ON

UPDATE YourTable
SET Column1 = Value1
WHERE <YourConditionGoesHere>

Select @@ROWCOUNT as [RowCount]
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
What we learned in Webroot's webinar on multi-vector protection.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 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