如何在 SQL (SSMS) 的存储过程中使用单列传递多行?或如何在过程中传递单列值。
CREATE TYPE tblAge_Type as TABLE
(
ID int,
Age int
)
--------------------------------------------------------------------------------------
alter PROCEDURE spAddAge (
@datasource tblAge_Type READONLY)
AS
update tblAge set Age = (select Age from @datasource ) where Id = (select ID from @datasource )
GO
------------------------------------------------------------------------------------------
DECLARE @data AS tblAge_Type
INSERT into @data VALUES(1,22) ;
INSERT into @data VALUES(2,55) ;
INSERT into @data VALUES(3,44);
EXEC spAddAge @data
收到此错误:子查询返回超过 1 个值。当子查询跟随 =、!=、<、<=、>、>= 或子查询用作表达式时,这是不允许的。