Solved

Can you create Static variables within SP ?

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

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

Suggested Solutions

Title # Comments Views Activity
T-SQL: Episode III - Revenge of The Dude 24 52
Help with SQL Server Polygon 2 32
sql 2014,  lock limit 5 31
SSIS with VPN COnnection 2 70
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

776 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