--建立測試環境 Create Table TEST (ID int, Name Varchar(100)) Insert TEST Select 1,'a' Union All Select 2,'b' GO --建立存儲過程 Create Proc ProcTestA As Select * from TEST GO Create Proc ProcTestB As Begin Create Table #T (ID int, Name Varchar(100)) Insert #T EXEC ProcTestA Select * from #T Where ID=1 End GO --測試 EXEC ProcTestB GO --刪除測試環境 Drop Table TEST Drop Proc ProcTestA,ProcTestB GO --結果 /* ID Name 1 a */
Create Table TEST
(ID int,
Name Varchar(100))
Insert TEST Select 1,'a'
Union All Select 2,'b'
GO
--建立存儲過程
Create Proc ProcTestA
As
Select * from TEST
GO
Create Proc ProcTestB
As
Begin
Create Table #T (ID int, Name Varchar(100))
Insert #T EXEC ProcTestA
Select * from #T Where ID=1
End
GO
--測試
EXEC ProcTestB
GO
--刪除測試環境
Drop Table TEST
Drop Proc ProcTestA,ProcTestB
GO
--結果
/*
ID Name
1 a
*/