SCOPE_IDENTITY()???  
Author Message
matthiaswessling





PostPosted: Tue Oct 18 10:20:36 CDT 2005 Top

SQL Server Developer >> SCOPE_IDENTITY()???

Hi All,
I have one doubt, if any one can help-me:

I have one SQL(db) that receive a lot of inserts, and I need get IDENTITY
value of current insert, but the machine have 4 processors.

If I use SCOPE_IDENTITY() I will get the corret value?

Thanks.

SQL Server96  
 
 
Aaron





PostPosted: Tue Oct 18 10:20:36 CDT 2005 Top

SQL Server Developer >> SCOPE_IDENTITY()??? Yes.




> Hi All,
> I have one doubt, if any one can help-me:
>
> I have one SQL(db) that receive a lot of inserts, and I need get IDENTITY
> value of current insert, but the machine have 4 processors.
>
> If I use SCOPE_IDENTITY() I will get the corret value?
>
> Thanks.
>


 
 
Jerry





PostPosted: Tue Oct 18 10:29:05 CDT 2005 Top

SQL Server Developer >> SCOPE_IDENTITY()??? Might want to try IDENT_CURRENT as SCOPE_IDENTITY is scope specific.

HTH

Jerry


> Hi All,
> I have one doubt, if any one can help-me:
>
> I have one SQL(db) that receive a lot of inserts, and I need get IDENTITY
> value of current insert, but the machine have 4 processors.
>
> If I use SCOPE_IDENTITY() I will get the corret value?
>
> Thanks.
>


 
 
Aaron





PostPosted: Tue Oct 18 10:36:04 CDT 2005 Top

SQL Server Developer >> SCOPE_IDENTITY()??? > Might want to try IDENT_CURRENT as SCOPE_IDENTITY is scope specific.

Actually, that is a lot more dangerous. Unless I read it wrong, the OP
wants the IDENTITY value generated by the current insert (SCOPE_IDENTITY),
not the most current IDENTITY value for the table (which may have changed
since the most recent insert in the current scope).

A