日期:2014-05-19  浏览次数:20440 次

求一条语句实现的问题
怎么用一条语句实现,如果一条记录存在,不插入,如果不存在则插入,比如说ID为4的存在就不插入,不存在就插入谢谢

------解决方案--------------------
If Not Exists(Select ID From 表 Where ID = 4)
Insert 表 (ID) Select 4
------解决方案--------------------
insert tba(cola,colb) select 'abc ',123 where not exists (select 0 from tba where id=4)