C#向数据库中插入一条不重复的记录

如果数据库中存在这条记录就不插入,如果不存在就插入。

insert into 表 (字段1 ,字段2,f_字段3) select top 1  @字段1值@字段2值,@字段3值  where not exists ( select 1 from 表 where 字段1=@字段1值 )

原文地址:https://www.cnblogs.com/zhenfeng/p/4439266.html