Is it possible in sql server using stored procedure to return the identity column value in a table against which some values are inserted? For example using stored procedure
Insert into TBL (Name, UserName, Password) Output Inserted.IdentityColumnName
Values ('example', 'example', 'example')
send an output parameter like
@newId int output
at the end use
select @newId = Scope_Identity()
return @newId
SELECT SCOPE_IDENTITY()
after the insert statement
Please refer the following links
http://msdn.microsoft.com/en-us/library/ms190315.aspx
You can use Scope_Identity() to get the last value.
Have a read of these too:
Here goes a bunch of different ways to get the ID, including Scope_Identity:
https://stackoverflow.com/a/42655/1504882
You can use SELECT @@IDENTITY as well