I assume you mean IDENTITY column? In this case, you can obtain the
last identity value inserted on the current connection with
value as an output parameter, return value or recordset. The example
below illustrates all three techniques.
CREATE TABLE MyTable
(
ID int NOT NULL IDENTITY(1,1)
)
GO
CREATE PROC usp_MyProc
AS
SET NOCOUNT ON
INSERT INTO MyTable DEFAULT VALUES
GO
GO
--
Hope this helps.
Dan Guzman
SQL Server MVP
-----------------------
SQL FAQ links (courtesy Neil Pike):
http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------
Quote:> Hi,
> I have a user table that contain a autonumber ID as primary key. I
would to
> write a stored procedure to insert record into this table and also
returns
> the autonumber ID as the return value of the stored procedure. But,
how do
> I capture the autonumber generated by each insert transaction since
Insert
> don't return any value.
> Thanks
> Jean