From: | "Magnus Hagander" <mha(at)sollentuna(dot)net> |
---|---|
To: | <Richard_D_Levine(at)raytheon(dot)com>, "Scott Marlowe" <smarlowe(at)g2switchworks(dot)com> |
Cc: | "lorid" <lorid(at)dri(dot)edu>, <pgsql-sql(at)postgresql(dot)org>, <pgsql-sql-owner(at)postgresql(dot)org> |
Subject: | Re: getting back autonumber just inserted |
Date: | 2005-02-04 14:48:44 |
Message-ID: | 6BCB9D8A16AC4241919521715F4D8BCE4767C5@algol.sollentuna.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Don Drake | 2005-02-04 21:18:37 | Re: Determining Rank |
Previous Message | q2005 | 2005-02-04 14:13:36 | the best way to get the first record from each group |