我使用以下命令在SQL Server 2012中创建了一个存储过程:
CREATE TYPE dbo.EncTypeFilter
AS TABLE
(
EncTypeFilterID int
);
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE GetExplorerData
@EncTypeFilterList AS dbo.EncTypeFilter READONLY
AS
BEGIN
...
END
我收到错误"操作数类型冲突:varchar与EncTypeFilter"不兼容当我用以下命令调用该过程时:
EXEC GetExplorerData @EncTypeFilterList='(1,2,3,4)'
那么,如何将Int列表作为参数传递给程序?
答案 0 :(得分:1)
您无法从varchar自动转换为表格内容。使用此:
DECLARE @EncTypeFilterList dbo.EncTypeFilter
INSERT INTO @EncTypeFilterList VALUES (1), (2), (3), (4);
EXEC GetExplorerData @EncTypeFilterList