Link to home
Start Free TrialLog in
Avatar of TraciShultz
TraciShultzFlag for United States of America

asked on

Can you create Static variables within SP ?

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
ASKER CERTIFIED SOLUTION
Avatar of Jay Toops
Jay Toops
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bukko
bukko

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