Solved

SQL combined functions in one stored procedure

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

815 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