Home Forums SQL Server 2008 SQL Server Newbies Adding record to db using stored procedure and identity counter. RE: Adding record to db using stored procedure and identity counter.

  • Just noticed you said you test environment is 2005

    You have to split up the declare and assign of the @newlVal variable.

    So

    SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

    BEGIN TRANSACTION;

    DECLARE @NewVal BIGINT;

    SELECT @NewVal = (SELECT MAX(member_id) FROM dbo.member WITH (TABLOCKX))+1;

    INSERT INTO dbo.Member (member_id, column list)

    VALUES (@NewVal, @params);

    COMMIT;

    Just a note you posted in a 2008 forum on here so GSquared gave you a 2008 answer.

    Cheers,

    Rodders...