本文介绍了如何为唯一列编写存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请有人告诉我如何在存储过程中插入唯一列,
就像我想通过存储过程将作为主键,名称,地址和电子邮件ID的ID插入表一样,
但要求是这样,重复的emailid不能通过存储的过程插入.
我该怎么做,我能够插入所有数据,但如何使emailid(允许重复的emailid)
请有人告诉.......
Pls some one tell that how to insert unique column in stored procedure,
Like i want to insert id which is primary key, name, address and emailid by the stored procedure into table,
but requirement is this, that duplicate emailid can not be inserted by stored procedue.
how can i do this, i am able to insert all data but how can i make emailid(dosent allow duplicate emailid)
pls some one tell this.......
推荐答案
IF NOT EXISTS(SELECT emailId FROM table where emailId = @emailId)
INSERT ...
这篇关于如何为唯一列编写存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!