select case when (select count(*) from 表 where userid=aa.userid)>1 then 'Userid重复!' else 'Email重复!' end from 表 aa

解决方案 »

  1.   

    Select UserID ,'' As Email From T1 Group By UserID Having Count(*) >1
    Union 
    Select '' As UserID , Email From T1 Group By Email Having Count(*) >1
    返回记录集
    若记录集中UserID<>'' 那么此ID重复,若EMAIL<>''那么EMAIL重复。
      

  2.   

    在insert前作判断:
    select * from table where userid=传进来的userid值
    if @@rowcount>0
    begin
    raiserror('用户名重复!')
    endselect * from table where userid=传进来的email值
    if @@rowcount>0
    begin
    raiserror('email重复!')
    end
      

  3.   

    if exists(select 1 from 表 where userid=@userid and email=@email)
    ....