--查询是否存在空格字段。
SELECT a.FNUMBER as '编码', b.FDATAVALUE as '名称',c.FNAME as '创建人',d.FNAME as '审核人'
FROM T_BAS_ASSISTANTDATAENTRY a
LEFT JOIN T_BAS_ASSISTANTDATAENTRY_L b
ON a.FENTRYID = b.FENTRYID
AND b.FLOCALEID = 2052
LEFT JOIN T_SEC_user c
on a.FCREATORID = c.FUSERID
LEFT JOIN T_SEC_user d
on a.FAPPROVERID = d.FUSERID
WHERE a.FID = '5cbfb58966b446' --辅助资料类型内码 规格
AND a.FDOCUMENTSTATUS = 'C'
AND a.FFORBIDSTATUS = 'A'
AND (LEFT(a.FNUMBER,1) = '' OR RIGHT(a.FNUMBER,1) = '')
--去除空格
update T_BAS_ASSISTANTDATAENTRY set FNUMBER = RTRIM(LTRIM(FNUMBER)) from T_BAS_ASSISTANTDATAENTRY a LEFT JOIN T_BAS_ASSISTANTDATAENTRY_L b
ON a.FENTRYID = b.FENTRYID
AND b.FLOCALEID = 2052
LEFT JOIN T_SEC_user c
on a.FCREATORID = c.FUSERID
LEFT JOIN T_SEC_user d
on a.FAPPROVERID = d.FUSERID
WHERE a.FID = '5cbfb58966b446' --辅助资料类型内码 规格
AND a.FDOCUMENTSTATUS = 'C'
AND a.FFORBIDSTATUS = 'A'
AND (LEFT(a.FNUMBER,1) = '' OR RIGHT(a.FNUMBER,1) = '')
推荐阅读