我有一个存储过程是这样写的:
Create procedure GetDetail_spas
begin
select t1.lastname,
t1.firstname,
t1.country,
t1.state,
t1.city
from table t1
union
select t2.lastname,
t2.firstname,
t2.country,
t2.state,
t2.city
from #Specified t2
end 这样执行存储过程后,实际上返回的就是个table,我怎么能接收这个table呢?
比如: exec GetDetail_sp
接着我想查出某个lastname的信息,select * from ?, 这个地方该怎么写?
Create procedure GetDetail_spas
begin
select t1.lastname,
t1.firstname,
t1.country,
t1.state,
t1.city
from table t1
union
select t2.lastname,
t2.firstname,
t2.country,
t2.state,
t2.city
from #Specified t2
end 这样执行存储过程后,实际上返回的就是个table,我怎么能接收这个table呢?
比如: exec GetDetail_sp
接着我想查出某个lastname的信息,select * from ?, 这个地方该怎么写?
create FUNCTION [dbo].[f_GetTable]()
RETURNS TABLE
AS
RETURN(
select 1 Id,'张三' name
union all select 2 Id,'李四' name
)查询
select * from [dbo].[f_GetTable]()