I don't know if you already solved this problem, but if the others will have the same problem:
If you are using a stored procedure, first you can declare a variable and than use set command to set the value of that variable and then use it in the following code:
DECLARE @idactual int
SET...