I have a single Column table with ID column as Identity. I need to have a Function that can Insert and Return Newly inserted Identity on Function call. I have created a function but we cant use INSERT in SCALAR functions. What else could be a solution
Share
You can use default function of sql server
Scope_Identity()to get the newly inserted identity field. Please refer the linkSCOPE_IDENTITY (Transact-SQL)
for more details.
You can make the same as stored procedure. Ex
Out put parameter can be retrieved by executing the stored procedure using
EXECcommand. Like