PLSQL 的写法:
begin
update tablename
set xxx=values;
exception
when no_data_found then
insert into tablename
valuse();
end ;
create proc InsertData(@id int)
as
begin
declare @count int
set @count =(select count(*) from 表名 where id = @id)
if @count>0
begin
update 表名 set 字段名='修改值' where id = @id
end
else
begin
insert into 表名(id,字段1,字段2) values('id1','值1','值2')
end
end
go
exec InsertData 1
exec InsertData 2
exec InsertData 3