I have a SP prc_Foo_Delete which has the following signature:
我有一个SP prc_Foo_Delete,它有以下签名:
ALTER PROCEDURE [prc_Foo_Delete]
@fooIds [int_udtt] READONLY,
@deleteReason int,
@comment nvarchar(512),
@deletedBy nvarchar(128)
int_udtt is define as:
int_udtt定义为:
CREATE TYPE [int_udtt] AS TABLE(
[Id] [int] NOT NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF)
)
I tried to call this SP in Management Studio with following script:
我尝试使用以下脚本在Management Studio中调用此SP:
DECLARE @return_value int
EXEC @return_value = [prc_Foo_Delete]
@fooIds = 3,
@deleteReason = 2,
@comment = N'asfdasdf',
@deletedBy = N'asdfa'
SELECT 'Return Value' = @return_value
GO
The error I got is: Operand type *: int is incompatible with int_udtt. How do I pass in a int or a list of int to call in this tool (I know how to do it in code but not in Management Studio).
我得到的错误是:操作数类型冲突:int与int_udtt不兼容。如何在此工具中传入int或int列表以进行调用(我知道如何在代码中执行此操作但不在Management Studio中执行)。
1 个解决方案
#1
38
Since you've defined your user defined type as a parameter on the stored procedure, you need to use that user-defined type, too, when calling the stored procedure! You cannot just send in a single INT
instead....
由于您已将用户定义类型定义为存储过程的参数,因此在调用存储过程时也需要使用该用户定义类型!你不能只发送一个INT而不是....
Try something like this:
尝试这样的事情:
-- define an instance of your user-defined table type
DECLARE @IDs [int_udtt]
-- fill some values into that table
INSERT INTO @IDs VALUES(3), (5), (17), (42)
-- call your stored proc
DECLARE @return_value int
EXEC @return_value = [prc_Foo_Delete]
@fooIds = @IDs, -- pass in that UDT table type here!
@deleteReason = 2,
@comment = N'asfdasdf',
@deletedBy = N'asdfa'
SELECT 'Return Value' = @return_value
GO
#1
38
Since you've defined your user defined type as a parameter on the stored procedure, you need to use that user-defined type, too, when calling the stored procedure! You cannot just send in a single INT
instead....
由于您已将用户定义类型定义为存储过程的参数,因此在调用存储过程时也需要使用该用户定义类型!你不能只发送一个INT而不是....
Try something like this:
尝试这样的事情:
-- define an instance of your user-defined table type
DECLARE @IDs [int_udtt]
-- fill some values into that table
INSERT INTO @IDs VALUES(3), (5), (17), (42)
-- call your stored proc
DECLARE @return_value int
EXEC @return_value = [prc_Foo_Delete]
@fooIds = @IDs, -- pass in that UDT table type here!
@deleteReason = 2,
@comment = N'asfdasdf',
@deletedBy = N'asdfa'
SELECT 'Return Value' = @return_value
GO