Solved

Can you create Static variables within SP ?

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

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

867 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

12 Experts available now in Live!

Get 1:1 Help Now