Solved

SQL combined functions in one stored procedure

Posted on 2011-09-12
2
267 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

19 Experts available now in Live!

Get 1:1 Help Now