You shouldn't use IDENT_CURRENT in the multi-user environment because it returns the last Identity value for a table regardless which session did the last INSERT. IOW, if between INSERT statement and retriving IDENT_CURRENT some other session inserts record, the Identity value returned would be not the one that belong to the record you inserted. I would recomentd the SCOPE_IDENTITY() because it's scoped to the current module (stored procedure, trigger, e.t.c.).
> I used IDEN_CURRENT mostly in my Store Proc. But in this case the IDEN_CURRENT returns .NULL. value, but when I use SCOPE_IDENTITY it works fine.I have a lot of store proc that uses IDENT_CURRENT() i just wondering if I have to re-write all those store proc.I there any idea or maybe im in the wrong track. tnx
>
>
>
>
>heres the scenario
>
>I have a view vPaymentDetail from "transdetail" table
>
>While (LOOP)
>begin
>
>
> insert into vPaymentDetail()--- Something
>
>
> set @PkTranDIDDeposit=IDENT_CURRENT('vPaymentDetail')
>
> -- RETURNS NULL
> print @PkTranDIDDeposit
>
>
> set @PkTranDIDDeposit=SCOPE_IDENTITY()
> -- RETURNS IDENTITY
> print @PkTranDIDDeposit
>
> --- SOME CODE FOR COUNTER
>
>
>end
--sb--