在我的存储过程中,我想检查一下以确保我试图插入的内容不存在于表中。我已经尝试了下面的代码,但它似乎给了我误报(即使它不在表格中也是如此)。有没有更好的办法?插入存储过程之前检查是否存在
if not exists (select myID from tableName where myID = @myID and otherColumn = @otherColumn)
begin
insert into tableName
(
myID
, otherColumn
) values (
@myID
, @otherColumn
)
end