Solved

SQL combined functions in one stored procedure

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

20 Experts available now in Live!

Get 1:1 Help Now