Re: @@Identity

From: Scott M. (NoSpam_at_NoSpam.com)
Date: 09/16/04


Date: Thu, 16 Sep 2004 17:49:02 -0500

My question is: do I need to do something to establish the Identity column
in the first place if the data is coming from an existing database that has
a primary key already set in the db?

How does VB.NET know which column I'm talking about when I use @@Identity?

"Mary Chipman" <mchip@online.microsoft.com> wrote in message
news:m93jk09dnd46jfv1hrjpvcv19i4q1m3gbs@4ax.com...
> Unless I'm misunderstanding your use of syntax, you are confusing the
> @@Identity function with a column with the identity property set.
> @@identity is used in the case where you have just inserted a new row
> in a table that has an identity column defined and you want to
> retrieve the new identity value. All of the "@@" globals are functions
> which return some kind of information from the server. So when
> selecting from a table with an identity column you simply refer to it
> by its column name, like any other column. If you are updating the
> row, omit the identity column from the update statement (except in the
> WHERE clause, where you refer to it by its column name). For more
> information on identity columns and @@identity, see SQL Books Online.
>
> --Mary
>
> On Thu, 16 Sep 2004 00:09:37 -0500, "Scott M." <NoSpam@NoSpam.com>
> wrote:
>
>>Thanks for your reply. I am using VB.NET, not C#, so I'm not sure what
>>your
>>code snippet is designed to do. If I have a simple SELECT like "SELECT *
>>FROM foo" and "foo" already contains a primary key in the db, would that
>>field automatically be the @@Identity field when it is brought into my
>>DataSet? If not, what would I do to mark the correct column as the
>>identity
>>field?
>>
>>Thanks.
>>
>>
>>
>>"Gaurav Vaish" <mDaOsNtOeTrSgPaAuMrPaLvS.nospam@nospam.lycos.com> wrote in
>>message news:%23YGCuk6mEHA.644@tk2msftngp13.phx.gbl...
>>>> 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.
>>>
>>>
>>> Hi,
>>>
>>> Directly use the value of the identity field. I assume that you know
>>> the
>>> name of the field. For example, if you have a table like:
>>>
>>> t_sample {
>>> id as autonumber,
>>> first as varchar(50),
>>> second as int
>>> }
>>>
>>> Doing a select that includes "id" as a field will give you the
>>> @@Identity (the autonumber). You can use this (columns["id"]) value
>>> during
>>> your update command.
>>>
>>> Does this answer your question? Or, then, can you provide your SELECT
>>> and UPDATE statements? That may things more visible!
>>>
>>> --
>>>
>>> Happy Hacking,
>>> Gaurav Vaish
>>> http://www.mastergaurav.org
>>> -----------------------------------
>>>
>>>
>>
>



Relevant Pages

  • Re: My Enterprise Architecture - your thoughts?
    ... > of Enterprise application architecture" is a bit of a misnomer as ... >> interface layer need change). ... database connection/display I would not say it has performance ... > I would refer to ...
    (comp.object)
  • Re: roffbib & sortbib for linux?
    ... but I can't seem to get it to understand my bib database. ... strings and has the refer macros defined: ... (but, for printing out a bibliography, GNU -ms works best; ... you are almost certainly going to want a sort line). ...
    (comp.os.linux.misc)
  • Re: My Enterprise Architecture - your thoughts?
    ... Personally my database schema is usually pretty close to my domain ... Are you testing it in the same physical deployment that you intend ... > ethernet connections to the servers. ... >> I would refer to ...
    (comp.object)
  • Company Contacts
    ... I am making a database for a call center so they can look up people, ... refer problems to the right people or give out correct adresses, ... I could have a subform for each breakdown- ie- company with a subform, ... Also- Each person has duties and (this is the most useful part of this ...
    (microsoft.public.access.tablesdbdesign)