sqlservice 存储过程 查询判断多表数据,存在则返回

declare @i  int;
declare @s nvarchar(max)
set @i=0;
set @s='xxxx';
select @i=count(*) from A where tiaoma=@s;
if(@i>0)
begin
select * from A where  tiaoma=@s;
end;
else
begin
select @i=count(*) from B where tiaoma=@s;
 IF(@I>0)
 BEGIN
select * from B where  tiaoma=@s;

 END
 ELSE
 BEGIN
 select @i=count(*) from c where tiaoma=@s;
 IF(@I>0)
 BEGIN
 select * from c where tiaoma=@s;
 END
 else
 begin
 print('没有找到')
 end
 END
end
原文地址:https://www.cnblogs.com/wangxlei/p/15001070.html