Solved

Can you create Static variables within SP ?

Posted on 2004-08-26
2
231 Views
Last Modified: 2008-03-06
I am trying to write a SP that will return me the next first record but I need to have a static variabel to seed my sp.

Any Ideas would vbe greatly apprecieated.

my SP is a s follows : I would like FirstCount to be static

CREATE PROCEDURE DestRackTest @TubeOrder  int  
AS


declare @ret_val nvarchar(50),
             @rackIndex Int,
             @FirstCount  int

SET @rackIndex =@Tubeorder % 96

IF @rackIndex = 1 AND @FirstCount > 0
BEGIN
     SET @FirstCount = @FirstCount + 1
     SET @ret_val = (SELECT Top 1 dbo.FinalDestRack .RackInfoID from dbo.FinalDestRack)
     DELETE FROM FinalDestRack where dbo.FinalDestRack.RackInfoID = @ret_val
     SELECT Top 1 dbo.FinalDestRack.RackInfoID
     FROM  dbo.FinalDestRack
END
 
ELSE
BEGIN
     SELECT Top 1 dbo.FinalDestRack.RackInfoID
     FROM dbo.FinalDestRack
END
GO
0
Comment
Question by:TraciShultz
[X]
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
2 Comments
 
LVL 10

Accepted Solution

by:
Jay Toops earned 500 total points
ID: 11904135
IF by static you mean that this needs to persist
just create a table for you control information
create a table called FirstCountinfo
and store that variable there.

Jay
0
 
LVL 8

Expert Comment

by:bukko
ID: 11904427
...or you could use a more generic named table, and store all your 'static' values there.
Or use the registry, of course.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

696 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