Solved

Can you create Static variables within SP ?

Posted on 2004-08-26
2
225 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
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

747 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

8 Experts available now in Live!

Get 1:1 Help Now