Re: @@Identity

From: Gabe Garza (spam_at_nospam.com)
Date: 10/14/04


Date: Thu, 14 Oct 2004 20:47:28 GMT

Actually I was thinking about this.
SCOPE_IDENTITY is better to use

So the problem you described wasn't because people are using IDENT_CURRENT
to get the identity value, it's because someone added some code to insert
into another table that had an identity in it.

Just wanted to correct myself before I get spammed.

But just to point out, @@IDENTITY isn't the real problem, it's when someone
adds code to insert into a table that has an identity value in it. That's
why Microsoft has SCOPE_IDENTITY, my guess.

"Scott M." <NoSpam@NoSpam.com> wrote in message
news:%23RsJyEQoEHA.3392@TK2MSFTNGP15.phx.gbl...
> Michael,
>
> I have no idea why you are insulting someone you don't know, who has never
> said anything to you. I think that says something about you.
>
> I also don't know why you are answering a question that has been answered
> already. I've gotten my answer, like 6 posts ago in this thread.
>
> I also think that you didn't really read this thread before you decided to
> stop beating your children and take whatever is pissing you off out on me.
> Clearly, my OP was understood as the first 2 replies answered my question.
>
> So, I'll say the same thing to you that I said to Roy. Perhaps you should
> not reply to posts that YOU don't understand?
>
>
> "Michael L John" <mjohn@emscharts.com> wrote in message
> news:evRL$0MoEHA.3684@TK2MSFTNGP10.phx.gbl...
> > Scott, you obviously are an idiot.
> > But, I will attempt to answer your LAST post because it is the only one
> > that makes sense.
> >
> > There are now 4 highly skilled and very experienced people that did not
> > understand anything you asked in your OP, so I guess all of them (us)
are
> > idiots.
> >
> > A SQL server database table can have one integer field designated as an
> > identity field. This value will auto increment when a new row is
inserted
> > into a table that has an identity field. The starting values, as well
as
> > the number that is incremented, can be defined by the user.
> >
> > If you are inserting a row with your ADO.Net code that will increment
the
> > identity value, and need to reliably retrieve this value, you can,
> > immediately after the INSERT statement, run "SELECT @@Identity". This
> > will return an integer that is the LAST IDENTITY VALUE inserted into a
> > table.
> >
> > As Bill pointed out, there are issues when using the GLOBAL SQL VARIABLE
> > @@identity.
> >
> > Assume you have 2 users that are both inserting a record in the same
> > table.
> > User A inserts record 10, user B inserts record 11. Unless your code
has
> > perfect timing, "SELECT @@identity" will return 11.
> > In a much worse case, assume there are 10 users inserting records into
10
> > tables with identity columns defined. In that case, who knows what
value
> > you may get back from "SELECT @@identity"
> >
> > You will be better served by using "SELECT SCOPE_IDENTITY()" in your
code.
> > The value returned by this FUNCTION is the identity specific to the
> > CURRENT SCOPE.
> >
> > As Mary also said, READ BOOKS ONLINE. This will make things much
clearer.
> > Unless you do not really know how to read.
> >
> > Good Luck
> > Michael L John
> >
> >
> > "Scott M." <NoSpam@NoSpam.com> wrote in message
> > news:ujJJ43FoEHA.3684@TK2MSFTNGP10.phx.gbl...
> >> Roy, I asked about @@Identity because I didn't know about it. If I
> >> misused the term "parameter", it was because I lacked the information I
> >> was looking for in the first place.
> >>
> >> The OP was not, as you say, "non-sensical". The other replies seemed
to
> >> have gotten what I was asking. Might I suggest that you not reply at
all
> >> if you don't understand the post?
> >>
> >>
> >> "Roy Fine" <rlfine@twt.obfuscate.net> wrote in message
> >> news:%23xhgyBEoEHA.3224@tk2msftngp13.phx.gbl...
> >>> Scott,
> >>>
> >>> read your orignal post - I said there is no such thing as an
@@Identity
> >>> parameter - that was what you were asking how to set. Your original
> >>> post
> >>> was nonsensical! your your own sake (and professional reputation) -
one
> >>> would have to strongly advise you against asking people to go back and
> >>> read
> >>> it.
> >>> roy
> >>>
> >>>
> >>> "Roy Fine" <rlfine@twt.obfuscate.net> wrote in message
> >>> news:%237Y%23LMDoEHA.592@TK2MSFTNGP11.phx.gbl...
> >>>>
> >>>> "Scott M." <NoSpam@NoSpam.com> wrote in message
> >>>> news:Oi$nLKpnEHA.2028@TK2MSFTNGP10.phx.gbl...
> >>>> > Wow Mary, thanks for the attitude!
> >>>> >
> >>>> > I don't know why you keep telling me that @@Identity it not
> >>>> > technically
> >>> a
> >>>> > field. I know that and it is beside the point of my question. It
> >>>> > does
> >>>> > return a field and it doesn't take a rocket scientist to figure
that
> >>>> > out
> >>>> > what I meant in my OP.
> >>>> >
> >>>>
> >>>> >> How do I set the @@Identity parameter for data that
> >>>> >> has been read in from a
> >>>> >> database? I have read in data via a command
> >>>> >> (SELECT statement) and am
> >>>> >> trying to build a good UPDATE statement and
> >>>> >> want to use the @@Identity field.
> >>>>
> >>>> Scott - I have read the above statement from your OP - and I have
read
> >>>> it
> >>>> several times sincethis thread has started, and I must say "your OP
> >>>> makes
> >>> no
> >>>> sense". There is no such thing as an @@Identity parameter - so I
would
> >>> walk
> >>>> away from the OP and try again.
> >>>>
> >>>> roy fine
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>
> >>
> >
> >
>
>



Relevant Pages

  • Re: @@Identity
    ... like 6 posts ago in this thread. ... This value will auto increment when a new row is inserted ... > into a table that has an identity field. ... > If you are inserting a row with your ADO.Net code that will increment the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Politics, not science, defines global warmists
    ... the mat - that the fact that his and *only* his responses are omitting ... See what a retard you are, you can't read worth a damn. ... posts that prevent them from being inserted. ... Other people inserting ">"'s manually OR using something other than the ...
    (rec.gambling.poker)
  • Re: Multiple Projects inserted in one.
    ... news reader -- much easier to see what's new and find posts again! ... If you have already created the master project, ... when inserting the subproject. ... Any changes made in the original copies of the subprojects will ...
    (microsoft.public.project)
  • Re: @@Identity
    ... Scott, you obviously are an idiot. ... If you are inserting a row with your ADO.Net code that will increment the ... Assume you have 2 users that are both inserting a record in the same table. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Problem: Identity seed
    ... What you're trying to do is in violation of the use of an identity ... Its sole purpose is to increment a value defined by the seed and ... > I have an Identity field in a table with many records. ...
    (microsoft.public.sqlserver.server)

Quantcast