选择值必须与插入列的数量匹配

选择值必须与插入列的数量匹配

我有以下查询...我检查并重新检查了 insert into 和 select 语句中的值的类型和数量。我不明白哪里出了问题。

insert into [Subscription].dbo.SUBSCRIPTION (
    CreateDate, 
    StartDate, 
    ProductId, 
    Processor, 
    IntervalType, 
    IntervalLength, 
    TotalOccurrences, 
    TrialOccurrences, 
    Status, 
    Amount, --10 
    TrialAmount, 
    FirstName, 
    LastName, 
    Address, 
    City, 
    State, 
    Zip, 
    Country, 
    Phone, 
    Email, --20
    CardNumber, 
    CardExpMonth, 
    CardExpYear, 
    Custom1, 
    Custom2, 
    Custom3, 
    SecurityCode, 
    CancellationDate, 
    ApplicationName, 
    OfferTypeID, --30
    OfferID, 
    CampaignID, 
    SubID, 
    OrderID) --34 items
select
    o.CreateDate, 
    DATEADD(day, 4, o.createdate) as startdate, 
    '3B85ECD0-6CC0-4A68-BFB1-922ADC74F5B0'
    'cb_test', 
    1, 
    1, 
    99, 
    0, 
    0, 
    59.84, --10
    0.00, 
    o.First_Name, 
    o.Last_Name, 
    o.Address_1, 
    o.City, 
    o.State, 
    o.Zip_Code, 
    o.Country, 
    o.Phone1, 
    o.Email, --20
    o.CC_Number, 
    o.CC_Exp_Month, 
    o.CC_Exp_Year, 
    'imported 1/11/2010', 
    null, 
    null, 
    '', 
    null, 
    'company', 
    null, --30
    o.ofid, 
    o.cid, 
    o.sid, 
    o.oid --34 items
from [pro].dbo.slp_Order o where o.oid> 7782221 and o.Isbilled = 1

答案1

您错过了语句的 SELECT 部分中 ProductID 值后面的逗号。

应该读:

'3B85ECD0-6CC0-4A68-BFB1-922ADC74F5B0',

答案2

订阅表是否有自动递增键?有些数据库要求您为 id 提供一个值,即使它被数据库覆盖。即

插入表2(id,name,address)从表b中选择0,myname,myaddress;

相关内容