为SELECT操作符(MS SQL SERVER)执行存储过程(如“表”)怎么做?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (15)

是否可以把SELECT操作符像表一样(MS SQL SERVER)一样执行存储过程?

就像是

SELECT TotalSum FROM exec MyStoreProcedure '2017/11/01', '2017/11/01'  

提问于
用户回答回答于

create proc proc1 as
select 1 as one, 2 as two

declare @result table (one int, two int)

insert into @result
exec proc1

select one from @result
用户回答回答于

create function dbo.TestTable
(@var1 bit)
returns table
AS
RETURN
( select *
    from INFORMATION_SCHEMA.TABLES
    where @var1 = 1
);


select * from
dbo.TestTable(1)

扫码关注云+社区