早安所有插入語句錯誤消息
我的老闆幫我設計它填充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)
感謝
韋恩
錯誤很明顯:您的INSERT語句定義了** 3列**您的SELECT語句返回** 6列**這將**從不**工作!列**的數量必須匹配** – 2013-02-19 09:35:22