Wise man or Wise guy? You Decide

Just another WordPress.com weblog

Bug in Scope_Identity() Function

Posted by sqlwiseguy on March 20, 2009

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: