本文介绍了查询插入新行如果不存在则不执行任何操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用控制台应用程序,我希望在表中插入数据,但是如果数据已经存在而不执行任何操作。

我的表名是统计信息,列是msg_id。如果表中已经存在msg_id而不是其他任何插入。

I am having console app from which I want to insert data in table but if the data already exists than do nothing.
My table name is statistics and column is msg_id. If the msg_id is already present in table than do nothing else insert.

推荐答案


if exists (select *From statistics where msg_id='')
begin
print 'exists'
end
else
begin
insert query
end


这篇关于查询插入新行如果不存在则不执行任何操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 19:04
查看更多