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
Solved

SQL combined functions in one stored procedure

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

792 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