大家帮我看一下这个问题:
在查询分析器里面能执行,但放到一个软件里作为报表来使用的时候就提示:
SQL ERROR CODE:260
260错误信息为:不允许从数据类型 %1! 到数据类型 %2! 的隐性转换(表 ''%3!'',列 ''%5!'')。请使用 CONVERT 函数来运行此查询。
SET NOCOUNT ON
DECLARE @ys money
SELECT @ys = CAST((z.NoPayMoney + isnull(m.NoPayMoney,0)) AS MONEY) FROM tblXskpMain m left join
(SELECT StaffID,sum(NoPayMoney) NoPayMoney FROM tblXskpMain
WHERE RatifyFlag<>'n' and NoPayMoney<>0 and StaffID is not null group by StaffID) z on m.StaffID=z.StaffID
SELECT m.xskpno as 单据号,c.cusno as 客商编号,c.cusname as 客商名称,f.staffno as 职员编号,f.staffname as 职员名称,
CASE WHEN (m.KPDate < c.HTStartDate or m.KPDate > c.HTEndDate) then '合同超期' ELSE '通过' END AS 合同超期标志,
CASE WHEN @ys > f.SaleLimit then '员工销售限额超出' ELSE '通过' END AS 员工销售限额超出标志,
CASE WHEN M.PayDate < GETDATE() then '客商应收超期' ELSE '通过' END AS 客商应收超期标志,
CASE WHEN S.PRICE < K.MinBulkPrice THEN '单价低入最小批发价' ELSE '通过' END AS 限价标志
FROM tblXskpMain m inner join
tblXskpSub s ON m.XSKPNo=s.XSKPNo left join
tblstock k on s.stkid=k.id left join
tblclient c on m.cusid=c.id left join
tblstaff f on m.OperatorNo=f.staffno
WHERE m.RatifyFlag = 'N'