Friday, March 23, 2012

how to get the inserted record id

This is a multi-part message in MIME format.
--=_NextPart_000_0048_01C47B19.C651B960
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
hi all
I have auto number field in my table with title ID
I wantted to know when we add a record in table, SQL server takes the = responsibility of increntin / adding auto number in field.
Please advise if there is any way to get this auto number from table. = Like we have table inserted and deleted ... ( getting maximum is not = working in multiple user environemnt ) Is there any stored procedure or = variable i can query ?
thanks.
Khurram Alam
--=_NextPart_000_0048_01C47B19.C651B960
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
hi all

I have auto number = field in my table with title ID
I wantted to know when we add a record = in table, SQL server takes the responsibility of increntin / adding auto number in = field.

Please advise if there is any way to = get this auto number from table. Like we have table inserted and deleted ... ( = getting maximum is not working in multiple user environemnt ) Is there any = stored procedure or variable i can query ?

thanks.
Khurram Alam


--=_NextPart_000_0048_01C47B19.C651B960--Select @.@.identity will give you the record just inserted.
You must be specifying some criteria for the deletes. When
you specify, do a select on that field.
>--Original Message--
>hi all
>I have auto number field in my table with title ID
>I wantted to know when we add a record in table, SQL
server takes the responsibility of increntin / adding auto
number in field.
>Please advise if there is any way to get this auto number
from table. Like we have table inserted and deleted ... (
getting maximum is not working in multiple user
environemnt ) Is there any stored procedure or variable i
can query ?
>thanks.
>Khurram Alam
>|||In SQL Server 2000, @.@.IDENTITY will work, however, in a high volume
multi-user environment, the BOL suggest that you use the SCOPE_IDENTITY()
function instead.
For more information, please see the Books Online
Rick Sawtell
MCT, MCSD, MCDBA
"ChrisR" <anonymous@.discussions.microsoft.com> wrote in message
news:0a4a01c47afa$aa5f6e10$a501280a@.phx.gbl...
> Select @.@.identity will give you the record just inserted.
> You must be specifying some criteria for the deletes. When
> you specify, do a select on that field.
>
> >--Original Message--
> >hi all
> >
> >I have auto number field in my table with title ID
> >I wantted to know when we add a record in table, SQL
> server takes the responsibility of increntin / adding auto
> number in field.
> >
> >Please advise if there is any way to get this auto number
> from table. Like we have table inserted and deleted ... (
> getting maximum is not working in multiple user
> environemnt ) Is there any stored procedure or variable i
> can query ?
> >
> >thanks.
> >Khurram Alam
> >
> >sql

No comments:

Post a Comment