Re: getting back autonumber just inserted

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Re: getting back autonumber just inserted
Дата
Msg-id 6BCB9D8A16AC4241919521715F4D8BCE4767C5@algol.sollentuna.se
обсуждение исходный текст
Ответ на getting back autonumber just inserted  (lorid <lorid@dri.edu>)
Список 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Richard_D_Levine@raytheon.com
Дата:
Сообщение: Re: getting back autonumber just inserted
Следующее
От: Don Drake
Дата:
Сообщение: Re: Determining Rank