我想做类似以下代码的事情:
WITH temp as (EXEC @return_value = [Transactions].[Myproc]
@Id = 1)
SELECT * from temp
是否可以在T-SQL中使用?
答案 0 :(得分:1)
以下是存储过程示例:
CREATE PROCEDURE [dbo].[sp_test]
AS
SELECT employee,first_name,last_name FROM employee_info
GO
以下是使用过程返回的结果集的示例:
DECLARE @EmployeeInfo as Table (
employee int,
first_name varchar(40),
last_name varchar(40)
)
INSERT INTO @EmployeeInfo
EXEC sp_test
SELECT * FROM @EmployeeInfo WHERE employee < 100 ORDER BY last_name