在第一个存储过程中,testList是用户定义的表类型
CREATE PROCEDURE [working].[test1] (@input1 int, @input2 testList READONLY) AS
BEGIN
// do some working
END
GO
CREATE PROCEDURE [working].[test2] (@input3 int, @input4 char) AS
BEGIN
// How can i convert char input4 to user defined table input testList
// I want to do that conversion because ,here i want to call stored procedure test1
EXEC [working].[test1] @input1 = @input3 , @input2 = CAST(@input4 AS testList);
// is this correct way to call ?
END
GO
答案 0 :(得分:1)
CREATE PROCEDURE [working].[test2]
@input3 int,
@input4 CHAR(N)
AS
BEGIN
SET NOCOUNT ON;
-- Declare a table variable of testList type
DECLARE @Table_Var AS testList;
-- Populate the table variable with value passed to @input4
INSERT INTO @Table_Var (ColumnName)
VALUES (@input4)
-- Now pass this table variable to your procedure
EXEC [working].[test1] @input1 = @input3
, @input2 = @Table_Var
END
GO