Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 return @@Identity from SP

Author  Topic 

Hommer
Aged Yak Warrior

808 Posts

Posted - 2005-11-22 : 10:21:12
Could somebody help me on this one please?
I have created a sp to insert data, as well as getting the ID back. Only the first part is working.

CREATE PROCEDURE [INV_setRollNum]
@Item varchar(50),
@ItemDesc varchar(50),
@PO varchar(50),
@Supplier varchar(50),
@WorkOrder varchar(50),
@NewID int Output
as
Set Nocount on
INSERT into Sts_RollNum (Item, ItemDesc, PO, Supplier, WorkOrderNum)
Values (@Item, @ItemDesc,@PO, @Supplier,@WorkOrder )
Select @NewID = @@Identity
Set Nocount off
GO
Running following tsql in QA, will insert the data, but no ID returned!
declare @NewID as int
exec INV_setRollNum '00100060','test','PO-67163','myself','234', @NewID
Print @NewID

Thanks!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2005-11-22 : 10:22:44
exec INV_setRollNum '00100060','test','PO-67163','myself','234', @NewID OUTPUT

-----------------
[KH]
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2005-11-22 : 11:12:39
Thanks a lot!
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-11-22 : 11:20:50
use SCOPE_IDENTITY().
Go to Top of Page
   

- Advertisement -