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

 

posted @ 2021-07-12 10:47  路边有一棵草  阅读(166)  评论(0编辑  收藏  举报