下面将为您介绍SQL函数返回表的示例,供您参考,如果您在SQL函数返回表方面遇到了问题,不妨一看,相信对您学习SQL会有所帮助。
create function [dbo].[GetOperateCustGroup]
(
@CustomerGuid varchar(36),
@StrategyOperateId varchar(36)
)
returns @TempTable table (MaxPrice float,MinPrice float,[Percent] float)
AS
begin
declare @CustomerGroupId int
select @CustomerGroupId = CustomerGroupId from T_CustGroupMember
where CustomerGuid = @CustomerGuid
set @CustomerGroupId=isnull(@CustomerGroupId,0)
insert into @TempTable
select MaxPrice,MinPrice,[Percent] from VC_T_StrategyOperateCustGroup
where CustomerGroupId = @CustomerGroupId
and StrategyOperateId=@StrategyOperateId
return
end
调用方式
SELECT * FROM [GetOperateCustGroup] ('12','22')
【编辑推荐】