如何访问存储过程中声明的 table 的 table 列的值?
How to access values of a table column of a table declared in stored procedure?
我的存储过程是:
alter PROCEDURE uspApprovalHistory
-- Add the parameters for the stored procedure here
@empID int = null
AS
BEGIN
declare @SRFTable table
(SRFID nvarchar(50))
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into @SRFTable
Select MasterCode from CallForwarding
Where EmployeeNo = @empID or ApproverNo = @empID;
Select * From callforwarding Where @SRFID[i] = Mastercode
END
GO
我想 select 来自 table 的所有行称为 CALLFORWARDING,其中 SRFID = MasterCode。但是有多个 SRFID 保存在名为 SRFTABLE 的 table 中。如何循环遍历 SRFTABLE 中所有不同的 SRFID,以从 CALLFORWARDING TABLE.
中获取所有匹配记录
这样的东西行得通吗?
Select * From callforwarding
Where Mastercode in (select distinct(SRFID) from SRFTABLE order by SRFID)
我的存储过程是:
alter PROCEDURE uspApprovalHistory
-- Add the parameters for the stored procedure here
@empID int = null
AS
BEGIN
declare @SRFTable table
(SRFID nvarchar(50))
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into @SRFTable
Select MasterCode from CallForwarding
Where EmployeeNo = @empID or ApproverNo = @empID;
Select * From callforwarding Where @SRFID[i] = Mastercode
END
GO
我想 select 来自 table 的所有行称为 CALLFORWARDING,其中 SRFID = MasterCode。但是有多个 SRFID 保存在名为 SRFTABLE 的 table 中。如何循环遍历 SRFTABLE 中所有不同的 SRFID,以从 CALLFORWARDING TABLE.
中获取所有匹配记录这样的东西行得通吗?
Select * From callforwarding
Where Mastercode in (select distinct(SRFID) from SRFTABLE order by SRFID)