create proc test
(
   @MobilePhone  varchar(70)
)
asif exists(select * from A where MobilePhone  = @MobilePhone)
  begin
      select * from A where MobilePhone  = @MobilePhone
  end
else
   begin
      if exists(select * from B where MobilePhone  = @MobilePhone)
        begin
            select * from B where MobilePhone  = @MobilePhone
        end
      else 
        begin
            if exists(select * from C where MobilePhone  = @MobilePhone)
               begin
                  select * from B where MobilePhone  = @MobilePhone
               end        end
   end

解决方案 »

  1.   

    create procedure proFindUser
         @chvMobileNum varchar(20)
      as 
        begin
           if(select A.MobilePhone from A where A.MobilePhone=@chvMobileNum)=@chvMobileNum
             begin
              select * from A where A.MobilePhone=@chvMobileNum
             end
           else if (select B.MobilePhone from B where B.MobilePhone=@chvMobileNum)=@chvMobileNum
             begin
              select * from B where B.MobilePhone=@chvMobileNum
             end
           else if (select C.MobilePhone from C where C.MobilePhone=@chvMobileNum)=@chvMobileNum
             begin 
              select * from C where C.MobilePhone=@chvMobileNum 
             end
        end
    GO