declare @UpMasterID varchar(50)
declare @ItemMasterID varchar(50)
set @ItemMasterID='a4a3b6b4-6a27-4174-ae2e-f38d719336da'
set @UpMasterID = @ItemMasterID
declare @hasUp int
set @hasUp = 1
while (@hasUp != 0)
begin
set @ItemMasterID = (select b.ItemMasterID
from CAPP_BaseInfo b where b.ID in (select c.BaseID from CAPP_BomLine c
where c.ItemMasterID=@UpMasterID))
set @hasUp = @@rowcount
if @hasUp != 0
begin
set @UpMasterID = @ItemMasterID
end
end
select @UpMasterID
比如
1
2
3
4
我从4向上找,就是要找到1,现在好像是死循环,查老长时间,请教高手,感激不尽!
数据库版本是?
啥意思呢.