我完全不熟悉數據庫的SQL Server部分。我創建了一個分離的Access數據庫,運行良好。Upsize訪問後端到SQL Server - 查詢問題
作爲一項測試,我將表升爲SQL服務器。大部分情況一切順利;但是,我的兩個查詢不再有效。他們都是相當複雜的聯合查詢。我相信工會是我的問題的罪魁禍首。
與第一個我有兩個查詢使用union all。他們單獨工作,但是當我使用聯合查詢時,我收到錯誤「對象無效或不再設置」。
隨着第二個我有3個查詢union all。這些比第一種情況更簡單。這次我收到錯誤「表達式輸入錯誤,或者它太複雜,無法評估。」
是否有關於在SQL服務器上使用表進行聯合查詢的具體內容?任何幫助或建議表示讚賞。
SELECT scrap.coilnum, Sum(scrap.lnff) AS sumoflnff, scrap.code, scrap.location
FROM scrap
WHERE scrap.day>=[Forms]![coilparameters]![Text0] And scrap.day<=[Forms]![coilparameters]![Text2] and scrap.productionline=[Forms]![coilparameters]![combo4] and scrap.coilnum<>0
GROUP BY scrap.coilnum, scrap.code, scrap.location;
union all
SELECT sawscrap.tcoilnum, Sum(sawscrap.length) AS sumoflnff, sawscrap.code, sawscrap.location
FROM sawscrap
WHERE sawscrap.day>=[Forms]![coilparameters]![text0] And sawscrap.day<=[Forms]![coilparameters]![text2] and sawscrap.productionline=[Forms]![coilparameters]![combo4] and sawscrap.tcoilnum is not null and sawscrap.tcoilnum<>0
GROUP BY sawscrap.tcoilnum, sawscrap.code, sawscrap.location;
UNION ALL
SELECT sawscrap.bcoilnum, Sum(sawscrap.length) AS sumoflnff, sawScrap.code, sawscrap.location
FROM sawscrap
WHERE sawscrap.day>=[Forms]![coilparameters]![text0] And sawscrap.day<=[Forms]![coilparameters]![text2] and sawscrap.productionline=[Forms]![coilparameters]![combo4] and sawscrap.bcoilnum is not null and sawscrap.bcoilnum<>0
GROUP BY sawscrap.bcoilnum, sawscrap.code, sawscrap.location;
還有第二個。
你能提供給出錯誤的SQL嗎?在SQL Server中的Union和Union All並不特殊。很簡單。 – Steve
除了表格本身之外,一切仍然處於Access狀態。 – jpw2007