declare @answerCount numeric(20);
begin
	begin tran
	begin try
		update Problem set status = '已完成' where status = '已回复';
		select @answerCount=count(*) from Answer;
		if (@answerCount = 0)
			begin
				insert into Answer (content, replyTime, problem_id) select answer, answerTime, id from Problem;
			end;
		commit tran
	end try
	begin catch
		rollback tran
	end catch
end;