How can we achieve the flow of execution in a Stored Proc and get a table output? Is this possible to call DEMO_PROC
and get the output of (SELECT DISTINCT * FROM #TEMP_TABLE
) mentioned in the proc? Or is there any alternate way by which this can be achieved?
Sample code:
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