File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Using SQL Server @@IDENTITY Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Using SQL Server @@IDENTITY" Watch "Using SQL Server @@IDENTITY" New topic
Author

Using SQL Server @@IDENTITY

Ian Morris
Greenhorn

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
return
 
wood burning stoves
 
subject: Using SQL Server @@IDENTITY