SELECT t0.FBILLNO,t0.FID,t0e.FENTRYID,t0e.FSTOCKORGID,t0e_b.FSETTLEORGID,t0.FDATE,t0.FCUSTID
INTO #TEMPTABLE
FROM T_SAL_ORDER t0
	INNER JOIN T_SAL_ORDERENTRY t0e on t0.FID = t0e.FID
	INNER JOIN T_SAL_ORDERENTRY_F t0e_b on t0e_b.FENTRYID = t0e.FENTRYID
WHERE 1=1
	AND CONVERT(int,Convert(varchar(6),t0.FDATE,112)) = 202410 
	AND t0.FCUSTID = 957286
	AND t0e_b.FSETTLEORGID != 1
/**************************************************************/
--UPDATE t0e_b SET t0e_b.FSETTLEORGID = 1
--FROM T_SAL_ORDER t0
--	INNER JOIN T_SAL_ORDERENTRY t0e on t0.FID = t0e.FID
--	INNER JOIN T_SAL_ORDERENTRY_F t0e_b on t0e_b.FENTRYID = t0e.FENTRYID
--WHERE 1=1
--	AND CONVERT(int,Convert(varchar(6),t0.FDATE,112)) = 202410 
--	AND t0.FCUSTID = 957286
--	AND t0e_b.FSETTLEORGID != 1