-1
我查詢不運行,但不返回任何結果:的MS Access/SQL Server的傳遞查詢
SET NoCount ON
SELECT
Inventory.EffectiveDate,
Inventory.Quantity,
Inventory.SourceType,
Inventory.PickingLocation,
Inventory.SourceInventory,
Locations.LocationId,
Customers.CustomerName,
Products.ProductId,
LocationFrom.LocationId as lFrom,
LocationTo.LocationId as lTo
FROM (((((((dbo.Inventory AS Inventory
LEFT JOIN dbo.Products AS Products ON Products.Product = Inventory.Product)
LEFT JOIN dbo.Locations AS Locations ON Locations.Location = Inventory.Location)
LEFT JOIN dbo.Customers AS Customers ON Customers.ConsignmentLocation = Inventory.Location)
LEFT JOIN dbo.Inventory AS SourceLocation ON SourceLocation.Inventory = Inventory.SourceInventory)
LEFT JOIN dbo.Locations AS LocationFrom ON LocationFrom.Location = SourceLocation.Location)
LEFT JOIN dbo.Inventory AS TargetLocation ON TargetLocation.Inventory = Inventory.TargetInventory)
LEFT JOIN dbo.Locations AS LocationTo ON LocationTo.Location = TargetLocation.Location)
WHERE
(Inventory.SourceType = 'Q' OR Inventory.SourceType = 'G' OR Inventory.SourceType = 'P' OR Inventory.SourceType = 'A' OR Inventory.SourceType = 'B')
AND
((Inventory.EffectiveDate >= 2011-12-30 And Inventory.EffectiveDate <= 2011-12-31));
該查詢從Excel罰款運行。但我一直在尋找能夠查看錶格的工具,這就是爲什麼我使用Access的原因 - 但它給了我更多的問題......
它實際上是相反的。如果我把它們放在引號中,我得到這個錯誤:'char數據類型轉換爲smalldaretime導致超出範圍值' – Elen 2012-02-23 17:38:58
'Inventory.EffectiveDate'的數據類型是什麼?如果您使用'YYYYMMDD'而不是'YYYY-MM-DD',會怎麼樣? – 2012-02-23 17:48:51
你引導我走向正確的方向!顯然它應該看起來像'30/12/11''謝謝你! – Elen 2012-02-23 17:56:46