Re: How do I read back autonumber after do an insert in asp.net



"T. DAVIS JR" <someone@xxxxxxxxxxx> wrote in
news:evSwa7enFHA.1048@xxxxxxxxxxxxxxxxxxxx:

> Well it depends on what database you are using. If you are using SQL
> Server this should work:
>
> SELECT @@Identity


@@IDENTITY is potentially a BAD thing! SELECT SCOPE_IDENTITY() is a
better choice since @@identity could return the wrong value if there are
triggers on the table.

Example:

http://www.trigonblue.com/sp_identity.htm

Here's a table explaining the difference:

SELECT @@IDENTITY <- Session Scope
SELECT IDENT_CURRENT('tablename') <- Table scope
SELECT SCOPE_IDENTITY <- statement scope


In detail:

http://www.sqlteam.com/item.asp?ItemID=319

--
Lucas Tam (REMOVEnntp@xxxxxxxxxx)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
.



Relevant Pages

  • RE: Backups have Shadow Copy Problems
    ... and restarted the server. ... suggested and changed the recovery model to simple on the one database called ... I understand the issue to be: the backup task failed ... You back up data from a volume that contains a Microsoft SQL Server ...
    (microsoft.public.windows.server.sbs)
  • Re: upsizing to sql 2005
    ... the word SERVER in it, ... You can access to the database by multiple means (Access, ... and how does it update the SQL database with the new records in Access? ... Query Name: Arcadia - ARC ...
    (microsoft.public.access.queries)
  • Re: Linked Tables in Access
    ... any use of SQL Passthru, Linked Tables or any other use of MDB / MDE ... server, or would I also need to convert *those* queries to passthrough ... I've been trying to understand why Access database files become corrupt. ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Leveling by ID vs. "Standard"
    ... of this trade called Project Management. ... a database for the "Project Tables," ... to write reports on data from the server database. ... product supporting queries created with SQL. ...
    (microsoft.public.project)
  • Re: Trouble Getting VS.Net 2003 WalkThroughs MSDE Connection
    ... Config Tool of SQL Server? ... > link to download the PUBs database. ... >>> Setup and they directed me to install MSDE and they attached a ...
    (microsoft.public.sqlserver.msde)

Loading