Thursday, March 19, 2009

Bug in Scope_Identity() Function

Aaron Bertrand (@AaronBetrand) tweeted this tonight.  Apparently there is a bug in SQL Server 2005/2008 with Scope_Identity() related to parallelism.  You can see the bug on Connect, here.  If a fix is important to you go and vote it up. 

This is a shock to me as I use Scope_Identity() regularly and now I have to re-evaluate it’s use.  I typically use stored procedures to do single row updates and use the Scope_Identity() function to return the id to the calling application using an output parameter.  Now it looks like I’ll have to use the Output clause which requires a table variable to hold it’s results.  Within the last 2 weeks I just told someone on SSC that is had been bullet-proof for me, it has, and was bug free.  I’ll have to go back and link to this.

No comments:

Post a Comment

So what do you think I am?