之前提出的问题,我相信我做了所有必要的转换,但我收到了错误:Error converting data type nvarchar to float
。错误消息引用SnapperMusic_Winman
- View1
视图1:
SELECT Products.ProductId AS Product, Products.ProductDescription AS Description, CONVERT(datetime, PurchaseOrders.EffectiveDate) AS OrderDate,
Suppliers.SupplierId AS SupplierAcc, Suppliers.SupplierName, CONVERT(datetime, Inventory.EffectiveDate) AS BookedDate, CONVERT(float, Inventory.Quantity)
AS Quantity, CONVERT(float, Inventory.TotalValue) AS TotalValue, Locations.LocationId AS Location, PurchaseOrders.PurchaseOrderId AS PONumber,
GoodsReceipts.GoodsReceiptId AS GoodsReference
FROM SnapperMusic_Winman.dbo.GoodsReceipts AS GoodsReceipts INNER JOIN
SnapperMusic_Winman.dbo.Inventory AS Inventory ON GoodsReceipts.GoodsReceipt = Inventory.GoodsReceipt INNER JOIN
SnapperMusic_Winman.dbo.Suppliers AS Suppliers ON GoodsReceipts.Supplier = Suppliers.Supplier INNER JOIN
SnapperMusic_Winman.dbo.Products AS Products ON Inventory.Product = Products.Product INNER JOIN
SnapperMusic_Winman.dbo.Locations AS Locations ON Inventory.Location = Locations.Location INNER JOIN
SnapperMusic_Winman.dbo.PurchaseOrderItems AS PurchaseOrderItems ON Inventory.PurchaseOrderItem = PurchaseOrderItems.PurchaseOrderItem INNER JOIN
SnapperMusic_Winman.dbo.PurchaseOrders AS PurchaseOrders ON PurchaseOrderItems.PurchaseOrder = PurchaseOrders.PurchaseOrder
视图2:
SELECT GoodsReceipts.ItemCode AS Product, dbo.StockItem.Name AS Description, CONVERT(datetime, dbo.POPOrderReturn.DocumentDate) AS OrderDate,
dbo.PLSupplierAccount.SupplierAccountNumber AS SupplierAcc, dbo.PLSupplierAccount.SupplierAccountName AS SupplierName, CONVERT(datetime,
dbo.POPReceiptReturnLine.DateTimeCreated) AS BookedDate, CONVERT(float, dbo.POPReceiptReturnLine.ReceiptReturnQuantity) AS Quantity, CONVERT(float,
GoodsReceipts.UnitBuyingPrice * dbo.POPReceiptReturnLine.ReceiptReturnQuantity) AS TotalValue, dbo.Warehouse.Name AS Location,
dbo.POPOrderReturn.DocumentNo AS PONumber, dbo.POPInvoiceCreditLine.POPInvoiceCreditNo AS GoodsReference
FROM dbo.POPOrderReturnLine AS GoodsReceipts INNER JOIN
dbo.POPReceiptReturnLine ON GoodsReceipts.POPOrderReturnLineID = dbo.POPReceiptReturnLine.POPOrderReturnLineID INNER JOIN
dbo.POPOrderReturn ON GoodsReceipts.POPOrderReturnID = dbo.POPOrderReturn.POPOrderReturnID INNER JOIN
dbo.PLSupplierAccount ON dbo.POPOrderReturn.SupplierID = dbo.PLSupplierAccount.PLSupplierAccountID INNER JOIN
dbo.Warehouse ON dbo.POPOrderReturn.WarehouseID = dbo.Warehouse.WarehouseID INNER JOIN
dbo.POPInvoiceCreditLine ON GoodsReceipts.POPOrderReturnLineID = dbo.POPInvoiceCreditLine.POPOrderReturnLineID INNER JOIN
dbo.StockItem ON GoodsReceipts.ItemCode = dbo.StockItem.Code
联:
SELECT dbo.Elen_GoodsInReceived_Winman.Product, dbo.Elen_GoodsInReceived_Winman.Description, dbo.Elen_GoodsInReceived_Winman.OrderDate,
dbo.Elen_GoodsInReceived_Winman.SupplierAcc, dbo.Elen_GoodsInReceived_Winman.SupplierName, dbo.Elen_GoodsInReceived_Winman.BookedDate,
dbo.Elen_GoodsInReceived_Winman.Quantity, dbo.Elen_GoodsInReceived_Winman.Location, dbo.Elen_GoodsInReceived_Winman.TotalValue,
dbo.Elen_GoodsInReceived_Winman.PONumber, dbo.Elen_GoodsInReceived_Winman.GoodsReference
FROM dbo.Elen_GoodsInReceived_Winman
UNION
SELECT dbo.Elen_GoodsInReceived_Sage.Product, dbo.Elen_GoodsInReceived_Sage.Description, dbo.Elen_GoodsInReceived_Sage.OrderDate,
dbo.Elen_GoodsInReceived_Sage.SupplierAcc , dbo.Elen_GoodsInReceived_Sage.SupplierName,
dbo.Elen_GoodsInReceived_Sage.BookedDate, dbo.Elen_GoodsInReceived_Sage.Quantity,
dbo.Elen_GoodsInReceived_Sage.TotalValue, dbo.Elen_GoodsInReceived_Sage.Location,
dbo.Elen_GoodsInReceived_Sage.PONumber, dbo.Elen_GoodsInReceived_Sage.GoodsReference
FROM dbo.Elen_GoodsInReceived_Sage
除转换后的字段外,所有其他字段均为VARCHAR
。
毋庸置疑,他们个人工作得很好..
任何人都可以指出我错过了什么吗?
答案 0 :(得分:3)
order
语句中select
列的某个位置错误。
在view1
中
dbo.Elen_GoodsInReceived_Winman.Location,
dbo.Elen_GoodsInReceived_Winman.TotalValue,
在view2
中
dbo.Elen_GoodsInReceived_Sage.TotalValue,
dbo.Elen_GoodsInReceived_Sage.Location,
将此顺序更改为合适。