在下面的代码中,我将多个值用逗号分隔到@i_CustomerGroupID和一个值到@ i_LocationID。其中我面临的问题是“子查询返回的值超过1 。当子查询遵循=,!=,<,< =,>,> =或当子查询用作表达式时,这是不允许的。 声明已被终止。“。请帮我解决问题。Sql插入错误 - “子查询返回超过1个值”
ALTER PROCEDURE [dbo].[spInsertCustomerGroupLocationMap]
-- Add the parameters for the stored procedure here
@i_LocationID int,
@i_CustomerGroupID varchar(100)
--WITH ENCRYPTION
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
IF NOT EXISTS (SELECT 1 FROM CustomerGroupLocationMap WHERE LocationID = @i_LocationID AND CustomerGroupID = @i_CustomerGroupID)
BEGIN
INSERT INTO CustomerGroupLocationMap (LocationID, CustomerGroupID) VALUES (@i_LocationID, (SELECT * FROM dbo.CSVToTable(@i_CustomerGroupID)));
END
END