my dog learned polymorphism*
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
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using SQL Server @@IDENTITY
 
Similar Threads
How to make this safe
How to know Identity columns of a table?
Binary datatype in MS SQL via JDBC
In need of automatic Id generator code
getting the last inserted value