I have an insert sql with sql server and then call select @@identity straight after, i am trying to use the identity id with a stored procedure, is this even possible
eg
insert into ...
select @@identity
EXEc add 'ss' @@identity
thanks
a
edit—
i basically want to use the value of the id which i’m getting now with
SELECT SCOPE_IDENTITY() ;
to use in a query straight after the insert.
Answering the (now deleted) question in the comments…
It is possible to use
@@IDENTITYdirectly in the parameter list of the stored procedure call. ForSCOPE_IDENTITY()(which you should be using to avoid problems if a trigger is later added to the table) this syntax is not allowed you need to use an intermediate variable as below.