In my stored procedure, I would like to check to make sure what I am trying to insert doesn't already exist in the table. I have tried the code below, but it seems to be giving me false positives (aka comes out to true even when it's not in the table). Is there a better way?
if not exists (select myID from tableName where myID = @myID and otherColumn = @otherColumn)
begin
insert into tableName
(
myID
, otherColumn
) values (
@myID
, @otherColumn
)
end