22,207
社区成员
发帖
与我相关
我的任务
分享
create table t_test(id int primary key,value varchar(50))
insert into T_Test
values(111,'aaa')
go
declare @id int
declare @value varchar(50)
set @id = 111
set @value = '111'
if exists(select 1 from t_test where id=@id)
update T_Test
set value = @value
where ID = @id
else
insert into T_Test
select @id,@value
--插入重复数据后,发现数据被更新了,没有报错
select *
from t_test