我编辑了我的问题:
我得到一个无效的对象名称“#Temp1”。下面的代码在游标循环中运行...
代码:
IF OBJECT_ID('tempdb..#Temp1') IS NOT NULL
BEGIN
DROP TABLE #Temp1
END
Insert Into #Temp1
Select o.EventSetName,
o.EventSetDisplay,
o.EventSetDescription,
o.ChildSetName,
ROW_NUMBER() Over (Order By o.ChildSetName) RN
From ##ObsSetLevel o,
##Final f
Where f.ChildSetName = o.EventSetName and
o.EventSetName = @ObsSetList
Order By o.ChildSetName asc
Insert into ##Final
Select *
From #Temp1
Where RN = 1
Union
Select '', '', '', ChildSetName, RN
From #Temp1
Where RN > 1