首页 > 数据库技术 > 详细

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

时间:2021-07-12 15:14:54      阅读:12      评论:0      收藏:0      [点我收藏+]
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

 

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

原文:https://www.cnblogs.com/wangxlei/p/15001070.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!