Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何从另一个存储过程中调用和使用存储过程?_Sql_Sql Server_Tsql - Fatal编程技术网

Sql 如何从另一个存储过程中调用和使用存储过程?

Sql 如何从另一个存储过程中调用和使用存储过程?,sql,sql-server,tsql,Sql,Sql Server,Tsql,我有以下表变量,填充此表的逻辑非常复杂,需要将其包含在单独的存储过程中: DECLARE @UserExtendedSecurity TABLE ( UserId UNIQUEIDENTIFIER, UserName VARCHAR(500), HasExtendedSecurity BIT ) 假设我将此逻辑封装在另一个名为GetUserExtendedSecurityData的存储过程中,该存储过程返回一个结果,其中的列映射到上面的@UserExtende

我有以下表变量,填充此表的逻辑非常复杂,需要将其包含在单独的存储过程中:

DECLARE @UserExtendedSecurity TABLE
(
    UserId UNIQUEIDENTIFIER,
    UserName VARCHAR(500),
    HasExtendedSecurity BIT     
)
假设我将此逻辑封装在另一个名为
GetUserExtendedSecurityData
的存储过程中,该存储过程返回一个结果,其中的列映射到上面的
@UserExtendedSecurity
表变量

假设我的主存储过程名为
GetUsers
,这就是我的主
@UserExtendedSecurity
表变量的定义位置

如何从
GetUsers
调用
GetUserExtendedSecurityData
,并将结果填充到主
@UserExtendedSecurity
表中

INSERT INTO @UserExtendedSecurityTable (UserName, HasExtendedSecurity)
EXEC GetUsers ...

GetUsers本身不返回任何结果,因此会填充GetUserExtendedSerSecurity数据的结果。

看起来像是正常的
插入到

CREATE PROCEDURE dbo.GetUsers 
AS 
BEGIN

/* some code */

DECLARE @UserExtendedSecurity TABLE
(
    UserId UNIQUEIDENTIFIER,
    UserName VARCHAR(500),
    HasExtendedSecurity BIT     
);

INSERT INTO @UserExtendedSecurity
EXEC GetUserExtendedSecurityData;

/* some more code */

END
请看这里: