declare @transactorid int set @transactorid=0 print(@transactorid) --exec sp_executesql n'select @transactorid=68 ',n'@transactorid int ',@transactorid exec sp_executesql n'select @transactorid=5 ',n'@transactorid int out ',@transactorid out print(@transactorid)