日期:2014-05-18 浏览次数:20539 次
if exists(select 1 from usertabel U inner join #tempJobPeopleLeaveTable T on U.username = T.username and U.sex = T.sex where T.id= @id) begin --更新 end else begin --添加 end
------解决方案--------------------
@id 是自定义的变量,表示传入的值
------解决方案--------------------
IF EXISTS(select id from #TempJobPeopleLeaveTable where id in (select id
from
userTable) )
begin
update userTable(userName ,sex )values(#TempJobPeopleLeaveTable.userName,#TempJobPeopleLeaveTable.sex)
where #TempJobPeopleLeaveTable.id=userTable.id
else
begin
select * from #TempJobPeopleLeaveTable insert into userTable
end
------解决方案--------------------
的确建议使用merge