我们如何在存储过程中实现执行流程并获得表输出?这是否可以调用DEMO_PROC
并获取SELECT DISTINCT * FROM #TEMP_TABLE
proc 中提到的 ( ) 的输出?或者有没有其他方法可以实现这一目标?
示例代码:
CREATE PROC DEMO_PROC AS
BEGIN
if object_id('Tempdb..#TMP') is not null
drop table #TMP
select
O.ID, O.NAME, O.E_ID, P.PKG_ID
into #TEMP_TABLE
from Order_Table AS O
join
Package_Table AS P on P.ID = O.ID
WHERE P.PKG_NAME IN (1,2)
ALTER TABLE #TEMP_TABLE ADD COL_V1 nvarchar(100);
UPDATE #TEMP_TABLE set COL_V1 = (SELECT assw FROM Order_Table AS O join ELEC_TABLE AS E ON O.E_ID = E.E_ID
where E.E_ID = #TEMP_TABLE.E_ID
and (E.E_DESC LIKE '%U R SUPER, Thanks! in advance%'))
SELECT DISTINCT * FROM #TEMP_TABLE
END