SELECT t0.FNUMBER,t0.FMATERIALID,t0_l.*,t1.税收分类编码,t0s.FTAXCATEGORYCODEID,t2.FID AS '税收分类编码ID',t2.FTAXPOLICY
--UPDATE t0s SET t0s.FTAXCATEGORYCODEID = t2.FID
--	,t0s.FTAXDISCOUNTSTYPE = t2.FTAXPOLICY
--	,t0s.FIsTaxEnjoy = CASE WHEN (LEN(t2.FTAXPOLICY) = 0) THEN 0 ELSE 1 END
FROM T_BD_MATERIAL t0
	INNER JOIN T_BD_MATERIALSALE t0s on t0.FMATERIALID = t0s.FMATERIALID
	INNER JOIN T_BD_MATERIAL_L t0_l on t0s.FMATERIALID = t0_l.FMATERIALID AND t0_l.FLOCALEID = 2052
	INNER JOIN (
		SELECT t1.货物名称,t1.税收分类编码
		FROM 税收分类编码导入EXCEL t1
		GROUP BY t1.货物名称,t1.税收分类编码
	) t1 on t0_l.FNAME = t1.货物名称
	INNER JOIN T_IV_GTTAXCODE t2 on t2.FTAXCODE = t1.税收分类编码
WHERE 1=1
	AND t0s.FTAXCATEGORYCODEID !=0