Kev Patil

Kev Patil

  • NA
  • 21
  • 4.3k

auto increment stored procedure

Jul 18 2017 4:13 PM
Hello,
 
I was able to get the following but not able to get the number to start from 900001.
 
DECLARE @new_seq INT=(
SELECT TOP 1
[NewNum] + 1
FROM [table] mo WITH(ROWLOCK,XLOCK,HOLDLOCK)
WHERE not([NewNum] is null) and NOT EXISTS
(
SELECT NULL
FROM [table] mi WITH(ROWLOCK,XLOCK,HOLDLOCK)
WHERE mi.[NewNum] = mo.[NewNum] + 1
)
ORDER BY
[NewNum]
);
IF @new_seq IS NULL
BEGIN SET @new_seq=900001;
END
ELSE
BEGIN SET @new_seq=@new_seq;
END
INSERT INTO dbo.[table]([NewNum]) VALUES(@new_seq);
 
Im trying to see which number is already there and whats missing, I would like for it to see between 900000 to 999999 but  this is what current data looks like:
 
NewNumber
904969
904984
904999
904998
905142
905141
 
I can put dummy record of 900000 then the above code will work but without putting that dummy info how can i get it to work?
 
Hope what i put up make sense.
Thanks 

Answers (2)

0
Andrea Angella

Andrea Angella

  • 0
  • 21.8k
  • 482.7k
Jun 30 2018 2:44 PM
It's very early days for Blazor. It's still an experimental project and I am not aware of any progressive web apps built with it. One of the main problem at the moment is that the runtime takes time to be downloaded on the client and this creates a long delay on first use. I wouldn't use it for now because it's not production ready. Please, I invite you to provide your feedback to the Blazor team.
 
I created a super simple introduction to Blazor that you can find here and shows you how you can give feedback or ask for features to the Blazor team:
  • https://aang.uk/2KAATmP 
You can join the conversation on Blazor in gitter at this address  https://gitter.im/aspnet/Blazor