Database : SQL Server 2008
Is there a way to have an insert statement return a value in SQL Server,
There is a similar question in
Return a value from a insert statement , which talks about ORACLE .
I don't work with databases much, and not aware of ORACLE/SQL Server much, so sorry to ask it all over again.
For simplicity let me provide a small example :
The table EmpDetails
has EmpiD
and EmpName
. The value of EmpID
is autogenerated by the database.
INSERT INTO EMPDETAILS VALUES("John")
Now I want to get the value of EmpID
associated with John
I don't want a stored procedure, I want a SQL statement only .
See Question&Answers more detail:os