Click here to Skip to main content
15,917,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get Id of table with the help insert procedure's return value
and how to show this value in asp.net web page.

SQL
create proc usp_ins_PaymentRcv
@id int OUTPUT,
@cid int,
@Amt int
as
Insert into PaymentRcv (CrFromCid,Amt) values (@cid,@Amt)
SET @ID=SCOPE_IDENTITY()
RETURN @ID
Posted
Updated 2-Dec-13 1:03am
v2
Comments
Vinodh.B 2-Dec-13 4:28am    
May I know what are you going to do with table id ?

DECLARE @IDs TABLE(ID INT);

-- minor change to INSERT statement; add an OUTPUT clause:
INSERT dbo.foo(name)
OUTPUT inserted.ID INTO @IDs(ID)
SELECT N'Fred'
UNION ALL
SELECT N'Bob';

SELECT ID FROM @IDs;

http://stackoverflow.com/questions/9477502/get-the-last-inserted-row-id-with-sql-statement[^]
 
Share this answer
 
Comments
Eng. Ashish Srivastava 2-Dec-13 5:07am    
and how to show this value in my web page using c#
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900