34,576
社区成员
发帖
与我相关
我的任务
分享
if not exists(select 1 from tb where A='X')
insert into tb select 'X'
--select '插入成功'
else
select '已存在'
declare @x table(a int primary key)
insert into @x select 1
select * from @x
--insert into @x select 1
--Cannot insert duplicate key in object 'dbo.@x'.
if not exists(select 1 from tb where A='X') insert into tb select 'X'
insert into X select @A where not exist (select 1 from X where A=@A)