Solved

SQL combined functions in one stored procedure

Posted on 2011-09-12
2
271 Views
Last Modified: 2012-05-12
Okay I was trying to be cheep with stored procedure memory and I am wonderin if any of you out there have any ideas.

1. I have 1 stored proce that calls 2 variables. Email and IRBTurnCounter, This proc calls for the lowest number (int) by desc so I get my email address to mail off the form with. Then I need the 'IRBTurnCounter' to increment by one so all the members of the table get called so everyone gets one email (eventually not at the run of this proc) Man I hope this makes sence!
2. What I have created works if ther are values placed in the fields at runtime... HOWEVER I need the values to be called and placed from the proc its self.  I would rather not do it in two procs but if I have to than I have to.

Thanks for all the help in advance

HD
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
Alter PROCEDURE [dbo].[P_sp_EmailerProgram]
	-- Add the parameters for the stored procedure here

	@Email nvarchar(50),
	@IRBTurnCounter int

AS

	/* SET NOCOUNT ON */
select top 1 Email, IRBTurnCounter from tbl_IRBMembors Order by  IRBTurnCounter Desc

	UPDATE tbl_IRBMembors
	SET 
IRBTurnCounter = @IRBTurnCounter + 1,
Email = @Email

WHERE Email = @Email

Open in new window

0
Comment
Question by:HawaiiDragon
2 Comments
 
LVL 8

Accepted Solution

by:
Crashman earned 500 total points
ID: 36524359
i really dont understand but

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
Alter PROCEDURE [dbo].[P_sp_EmailerProgram]
AS
	/* SET NOCOUNT ON */
DECLARE @Email nvarchar(50),
@IRBTurnCounter int

Select top 1 @Email = Email, @IRBurnCounter = IRBTurnCounter from tbl_IRBMembors Order by  IRBTurnCounter Desc

UPDATE tbl_IRBMembors
SET 
IRBTurnCounter = @IRBTurnCounter + 1,
Email = @Email
WHERE Email = @Email

Open in new window

0
 

Author Closing Comment

by:HawaiiDragon
ID: 36524404
For not understanding YOU NAILED IT Thank you!!!!
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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