这是我尝试执行的WinSQL查询。
SELECT ezait6 AS "MO No",
vhitno AS "Item No",
vhrefd AS "Finish Date",
vhmaqa AS "Manuf Qty",
vhmaun AS "U/M"
FROM m3edbtest.mwohed,
m3edbtest.cinacc
WHERE ezcono = 1
AND vhcono = ezcono
AND vhrefd >= '20170801'
AND vhrefd <= '20170831'
AND vhmfno = ezait6;
- 不同的数据类型
- vhmfno ==&gt;整数
- ezait6 ==&gt;的nchar(8)
运行查询后,出现以下错误:
-- Error : SQL0802 - Data conversion or data mapping error.
我怀疑它是由不同的数据类型组成的 我的一个表“ezait6”中有一个nvarchar列。 那么我应该如何将这些值转换为INT类型。
答案 0 :(得分:0)
您可以先检查varchar字段的内容是否为数字,并仅查询这些内容:
SELECT ezait6 AS "MO No",
vhitno AS "Item No",
vhrefd AS "Finish Date",
vhmaqa AS "Manuf Qty",
vhmaun AS "U/M"
FROM m3edbtest.mwohed,
m3edbtest.cinacc
WHERE IsNumeric(ezait6)=1
AND ezcono = 1
AND vhcono = ezcono
AND vhrefd >= '20170801'
AND vhrefd <= '20170831'
AND vhmfno = CONVERT(INT,ezait6);