Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Manual Auto Number

Author  Topic 

wirawan
Starting Member

1 Post

Posted - 2009-06-28 : 22:33:47
Hi

I have StoredProcedure like this

CREATE Procedure savenextmoveerfnrstr

@erfdat as datetime,
@area as integer
As
insert into umzuege (erfnr,ErfDat,area,status) (SELECT ISNULL(MAX(ErfNr) ,0) +1 AS erfnr,@erfdat,@area,'Erfassung' FROM Umzuege where (area=@area) AND (Year(ErfDat)=Year(@ErfDat)))
Select @@Identity as 'UmID'
return

where will create an increment of erfnr with the condition.

My question is:
for example
we have erfnr 578, 579, 581, 582
where the 580 is missing
What could be the problem, instead deleting proccess?
Could it be because it procced by 2 user in a same time?

Please help me
Thanks


bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-06-29 : 00:08:12
u can use identity function identity(578,1)
see this link it may help
http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server
Go to Top of Page
   

- Advertisement -