File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Using SQL Server @@IDENTITY Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Using SQL Server @@IDENTITY" Watch "Using SQL Server @@IDENTITY" New topic

Using SQL Server @@IDENTITY

Ian Morris

Joined: May 23, 2001
Posts: 7
Please can somebody help with the following question. I am working on a JSP/Servlet application, my servlet inserts a record into a table with an identity column(SQL Server 7). How can I do a "select @@IDENTITY" to see what the last identity inserted was. I would like to capture the identity and display it back using a JSP. Thanks.
Daniel Dunleavy
Ranch Hand

Joined: Mar 13, 2001
Posts: 276
If you write a procedure call to do it you can return it as a result at the end in either a parm out field or a select result like ....

ret_id = @@identity
select ret_id
I agree. Here's the link:
subject: Using SQL Server @@IDENTITY
It's not a secret anymore!