insert into Attributes (Id, Disabled, AttributeValue)
values (@id, @disabled, @attr_value)
if not exists
(
select * from Attributes
where
Id = @id
)
Run Code Online (Sandbox Code Playgroud)
我也检查了这些问题.但是,如果不存在,它似乎没有插入使用的查询. 只有插入行,如果它不是已经存在和 SQL条件插入如果行不存在
Tar*_*ryn 10
将其更改为 INSERT INTO SELECT
INSERT INTO Attributes (Id, Disabled, AttributeValue)
SELECT @id, @disabled, @attr_value
WHERE NOT EXISTS
(
select * from Attributes
where
Id = @id
)
Run Code Online (Sandbox Code Playgroud)
你需要执行这样的事情
IF NOT EXISTS (select 1 from Attributes where Id = @id)
BEGIN
insert into Attributes (Id, Disabled, AttributeValue)
values (@id, @disabled, @attr_value)
END
Run Code Online (Sandbox Code Playgroud)
这通常是通过 else 子句来更新行(如果存在)来完成的。
| 归档时间: |
|
| 查看次数: |
10718 次 |
| 最近记录: |