我在 SQL Server 2005 中收到以下错误消息
消息 120,级别 15,状态 1,过程 EPIN,第 37 行
INSERT 语句的选择列表包含的项目少于插入列表。SELECT 值的数量必须与 INSERT 列的数量相匹配。
我已将选择列表和插入列表复制并粘贴到 excel 中,并验证每个列表中的项目数量相同。两个表的附加主键字段都没有在插入语句或选择列表中列出。我不确定这是否相关,但可能是可疑的。
这是我的存储过程的来源:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: Kristian Manuel
-- Create date: 10/3/2012
-- Description:
-- =============================================
ALTER PROCEDURE [dbo].[EPIN]
-- Add the parameters for the stored procedure here
@PLUCODE varchar(30), --Table tblPolicy
@ECPAYFEES numeric(18,2),
@COSTPAYABLE numeric(18,2),
@RETAILPRICE numeric(18,2),
@DENOMINATION varchar(50),
@CARDNAME varchar(50),
@DistributorID varchar(8),
@AccntID decimal(18,0)
--PO1
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
INSERT INTO [ECPAY-PC].[GENESIS].[dbo].[tblPolicy]
(
PolicyID ,
AccountTID ,
DistributorID ,
CARDNAME ,
DENOMINATION ,
RETAILPRICE ,
COSTPAYABLE ,
ECPAYFEES ,
PLUCODE
)
SELECT
t.*
FROM
(SELECT
AccountTID = @AccntID,
DistributorID = @DistributorID,
CARDNAME = @CARDNAME,
DENOMINATION = @DENOMINATION,
RETAILPRICE = @RETAILPRICE,
COSTPAYABLE = @COSTPAYABLE,
ECPAYFEES = @ECPAYFEES,
PLUCODE = @PLUCODE) t,
[ECPAY-PC].[ECPNWEB].[dbo].[account] a
WHERE
a.AccntID = t.AccountTID --for account
END