Constraints check: TRY/CATCH vs Exists()

后端 未结 5 1818
面向向阳花
面向向阳花 2020-12-11 16:55

I have a table with unique constraint on it:

create table dbo.MyTab
(
    MyTabID int primary key identity,
    SomeValue nvarchar(50)
);
Create Unique Index          


        
5条回答
  •  眼角桃花
    2020-12-11 17:40

    Why not implement a INSTEAD OF INSERT trigger on the table? You can check if the row exists, do nothing if it does, and insert the row if it doesn't.

提交回复
热议问题