有人可以告诉我为什么这行不通吗?
我有一个返回表的存储过程:像这样调用它可以正常工作:
EXECUTE dbo.sp_Get_Total_Parcels_Paid_Data
但是,我需要在视图中使用它,并且不能让它工作。
Select * from dbo.sp_Get_Total_Parcels_Paid_Data()
错误:
无效的对象名称'dbo.sp_Get_Total_Parcels_Paid_Data()
SP代码:
create PROCEDURE [dbo].[sp_Get_Total_Parcels_Paid_Data]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @Sql1 nvarchar(max)
,@Sql2 nvarchar(max)
,@Sql3 nvarchar(max)
declare @TallyResults table
(EFOLDERID nvarchar(31) null
,inv_bank_cd int null
,inv_cd int null
,inv_group_cd int null
,intLoanNumber int null
,other_text nvarchar(250) null
,tallyCount int
,eidMgrId nvarchar(31))
select @Sql1 = 'Select ' + tallydefinition from jobfunctions where jobfuncid = 44
select @Sql2 = 'Select ' + tallydefinition from jobfunctions where jobfuncid = 45
select @Sql3 = 'Select ' + tallydefinition from jobfunctions where jobfuncid = 206
insert into @TallyResults exec sp_executesql @Sql1
insert into @TallyResults exec sp_executesql @Sql2
insert into @TallyResults exec sp_executesql @Sql3
select * from @TallyResults
END