大家早上好
我的老板帮助我设计了一个查询,其中填充了 137 万行随机数据,他现在要求我将结果插入/更新到空白表中。但由于某种原因,我无法让它工作。
三列是 ArrivalDate、PitchType_Skey 和 Site_Skey。但是当我运行我的查询(见下文)时,我收到一条错误消息,我不知道为什么。你能帮我吗?
消息 121,级别 15,状态 1,第 2 行
INSERT 语句的选择列表包含的项目多于插入列表。SELECT 值的数量必须与 INSERT 列的数量相匹配。
询问:
USE Occupancy
INSERT INTO Bookings (ArrivalDate, Site_Skey, PitchType_Skey)
SELECT
Time.Date, Site.Site_Skey, Site.SiteWeighting, PitchType.PitchType_Skey,
PitchType.PitchTypeWeighting,
RAND(checksum(NEWID())) * Site.SiteWeighting * PitchType.PitchTypeWeighting AS Expr1
FROM
Capacity
INNER JOIN
Site ON Capacity.Site_Skey = Site.Site_Skey
INNER JOIN
PitchType ON Capacity.PitchType_Skey = PitchType.PitchType_Skey
INNER JOIN
Time
INNER JOIN
AGKey ON Time.ArrivalDayWeighting = AGKey.[Key] ON Capacity.StartDate <= Time.Date AND Capacity.EndDate >= Time.Date
CROSS JOIN
(SELECT 0 AS col1
UNION ALL
SELECT 1 AS col1) AS aaav
WHERE
(Time.CalendarYear = 2010)
AND (RAND(checksum(NEWID())) * Site.SiteWeighting * PitchType.PitchTypeWeighting >= 1.22)
谢谢
韦恩