how to returning a table id..

  • Thread starter Thread starter smen
  • Start date Start date
S

smen

hiye, i use sqlcommand.executescalar to insert datainto
my table hoping that it will return the table id, but its
not :(. can someone uot there tell mehows its done?

thanks in advance.
 
assuming this table id is an IDENTITY field

CREATE Procedure spAddSomething
(
@SSNO char(9),
@FirstName nvarchar(15),
@MidName nvarchar(15),
@LastName nvarchar(25)
)

AS

INSERT tblWhatever (
SSNO,
FirstName,
MidName,
LastName
) Values (
@SSNO,
@FirstName,
@MidName,
@LastName
)

SELECT @@IDENTITY AS 'Table_ID'

GO

Hope this helps

Shane
 
Back
Top