try..
Begin
if @Qty is null
begin
set @Qty=0
begin
UPDATE StockInBranches SET Qty = @Qty +
isnull(Cast(Select Qty from StockInBranches Where ItemCode = @ItemCode and BranchName = @BranchName) as int),0) Where
ItemCode=@ItemCode and BranchName = @BranchName
end
End