From: Magnus Hagander <mha@sollentuna.net>
To: Richard_D_Levine@raytheon.com
To: Scott Marlowe <smarlowe@g2switchworks.com>
Cc: lorid <lorid@dri.edu>
Cc: pgsql-sql@postgresql.org
Cc: pgsql-sql-owner@postgresql.org
Subject: Re: getting back autonumber just inserted
Date: Fri, 4 Feb 2005 15:48:44 +0100
Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE4767C5@algol.sollentuna.se> (raw)
> I don't work with M$ DBs, but saw that "autonumber" is an M$ concept.
> Purely for my own edification, how do you get the most resent
> value of an autonumber in M$? I was helping someone out who
> was using M$ stuff and was amazed that there was no currval function.
I beleive they call it IDENTITY and not autonumber.
You get it using either
SELECT @@IDENTITY
or
SELECT SCOPE_IDENTITY()
depending on if you want the very latest identity or the latest int he
current scope (if you have a trigger inserting records in a different
table, they will differ - @@IDENTITY will return from the table affected
by the trigger, SCOPE_IDENTITY() will return it for the table *you*
updated)
//Magnus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: mha@sollentuna.net, Richard_D_Levine@raytheon.com, smarlowe@g2switchworks.com, lorid@dri.edu, pgsql-sql-owner@postgresql.org
Subject: Re: getting back autonumber just inserted
In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCE4767C5@algol.sollentuna.se>
References: <6BCB9D8A16AC4241919521715F4D8BCE4767C5@algol.sollentuna.se>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox