使用左功能条件SQL Server选择

时间:2018-01-30 03:14:21

标签: sql-server case

任何人都可以帮助解决此问题吗?

SELECT        TOP (200) Material, Plant, StorLocation, Batch, 
LEFT(Batch, 1),
CASE WHEN LEFT(Batch, 1) <> '0' THEN 
    Batch  
ELSE 
    CONVERT(INT, Batch)
END AS BATCH, 

MaterialDescription, SLDays, Days, SLEDBBD, Unrestricted, BUn, Location, Status
FROM            ZMB5M
WHERE BATCH = '67918688Q0'

但它返回错误:

Msg 245, Level 16, State 1, Line 2
Conversion failed when converting the nvarchar value '67918688Q0' to data type int.

批处理在nvarchar中,我想要批量删除有一些&#39; 0&#39;在数据开始 感谢..

0 个答案:

没有答案