这是我的问题:从ProductVendor表中选择所有行,并从度量单位表中选择相应的数据。显示产品供应商表中的列BusinessEntityID,ProductID,StandardPrice和度量单位表中的名称。写这2种不同的方式 - 1使用连接,另一种使用WHERE子句。 (10分)将nvarchar值'Bottle'转换为数据类型时,转换失败int
这是我的代码:
USE AdventureWorks2008R2;
SELECT CAST(Name as INT),BusinessEntityID, ProductID, StandardPrice, Name
FROM Purchasing.ProductVendor Right Outer JOIN Production.UnitMeasure
ON Purchasing.ProductVendor.BusinessEntityID = Production.UnitMeasure.Name
而且我不断收到此错误:转换为nvarchar值“瓶”到的数据类型为int时转换失败。
你为什么铸造'Name'作为'Int' ? –
'SELECT 42 AS Name,...' – zerkms
那么,因为我必须从一种数据类型转换为另一种,所以我应该使用Convert(int,Name)? – necea0612