Question : exec @var1 = sprocname @var2

This runs fine (and I see the sproc output) but on my very next line where I update a table and
set fieldname = @var1
the value of var1 = 0

Should @var1 not contain the result from the SP?
var1 is declared as varchar(500)

Answer : exec @var1 = sprocname @var2

@var1 , contain the return valueu of the sp, it usually indicates whether the sp execution was success.
in order to get the resultset of an sp call
you have to declare a temple table exactly the same no of columns and datatype the sp is returning, and populate that table like this

insert into #temp
EXEC spName @var2

after that you can use this table to update the values on the other table

or if the sp is returning just a value, you can use output parameters or even you can convert that sp to a user defined function
Random Solutions  
 
programming4us programming4us