This really worries me! Why do you think 'sometimes' it works and 'sometimes' it doesn't.
Do you insert just ONE row immediately followed by set @i=@@identity?
How do you access the database when this happens? Can you reproduce it in Management Studio. Or is it happening via something like JDBC or .NET?
commented on Mar 6 2012 3:29AM