27,581
社区成员




if not exists(select 1 from 表名 where 列名=值) then
--插入数据
else
--
--1
使用unique 约束 在相应字段上
--2
在相应字段 用主键
--3
建立触发器
if not exists(select 1 from 表名 where 列名=值)
--插入数据
else
begin
--该错误前台可以捕捉到。
raiserror('该用户名已经存在!',16,1)
return
end