>Hello Fabio,
>
>>you want to complicate the simple things.
>
>No I don't - honest! Always grateful for ideas to make my work easier, but at the same time I need to understand what is going on. Incidentally, why the line SET LOCK_TIMEOUT 5000?
If another user lock the same record, sql wait for 5s before raise a error.
>
>>If you don't check the return value of SQLEXEC() the program cannot work to along.
>
>I used the code you supplied, and it works fine until it has created around 4000 new id values, then SQL-server crashes with the messages I mentioned previously.
>
How long do the new 4000 ids require?
try this:
....
TEXT TO lcSQLCmd TEXTMERGE NOSHOW
DECLARE @newId INT
SET NOCOUNT ON
SET LOCK_TIMEOUT 1000
-- OPTIONAL
-- WAITFOR DELAY '0:0.05'
UPDATE UniqueId
SET @newId= nLastNumber = nLastNumber+1
WHERE UPPER(cFieldName) = '<<lcFieldName>>'
SELECT @newId AS nNewNumber
ENDTEXT
...
>Regards,
>Alan