IF OBJECT_ID('Temp_expo') is not null
begin
drop table Temp_expo
end
set @query3 = 'SELECT SPCT_ID_REL_LOW,SPCT_ID_REL_HIGH,ROW_NUMBER() over (order by PDBC_PFX) as TempId
INTO Temp_expo
FROM ['+ @FCTServer +'].['+@FCTDBName+'].dbo.CMC_SPCT_SUPP_CONV
where SPCT_ID_REL_LOW <> '''' and SPCT_ID_REL_HIGH <> '''''
exec (@query3)
Select @minCount= min(TempId) from Temp_expo
Select @maxCount= max(TempId) from Temp_expo
create table #ICD9SPCT
(
ICD9Code varchar(200)
}
while @minCount<=@maxCount
begin
select @low=SPCT_ID_REL_LOW,@high=SPCT_ID_REL_HIGH
from Temp_expo
where TempId=@minCount
group by SPCT_ID_REL_LOW,SPCT_ID_REL_HIGH
set @loworder = (select ISNULL(OrderId,0) from FCT_ICD9_Diag_ORDER where ICD9=@low)
set @highorder = (select ISNULL(OrderId,0) from FCT_ICD9_Diag_ORDER where ICD9=@high)
insert into #ICD9SPCT
select ICD9 from FCT_ICD9_Diag_ORDER ordert
left join #ICD9SPCT icdorder on ordert.ICD9 = icdorder.ICD9Code
where OrderId between @loworder and @highorder and icdorder.ICD9Code is null
set @minCount = @minCount+1;
end
以上是我收到此错误的代码。我发现错误是由于下面的代码请帮助
set @loworder = (select ISNULL(OrderId,0) from FCT_ICD9_Diag_ORDER where ICD9=@low)
set @highorder = (select ISNULL(OrderId,0) from FCT_ICD9_Diag_ORDER where ICD9=@high)