日期:2014-05-17 浏览次数:20478 次
if exists(select 1 from tableB where id =1)
begin
update TableB set ** where id =x
end
else
begin
insert into TableB values ('')
end
--假设你保存后的表为A,要处理的表为B
UPDATE B
SET b.xx=a.xx ,.....这里把你要更新的列写上
FROM B INNER JOIN A ON B.主键=A.主键
INSERT INTO B
SELECT *
FROM A
WHERE NOT EXISTS (SELECT 1 FROM B WHERE B.主键=A.主键)