--
SELECT * FROM dbo.Dict_FeeItem   -- where FeeItemCode<>''
SELECT top 200 * FROM peis.dbo.FeeItem -- where HISCheckCode<>''

select * from Dict_FeeItem a left join Dict_ReportItem b on a.id=b.fid where b.fid=44
--
TRUNCATE TABLE Dict_FeeItem

SET IDENTITY_INSERT dbo.Dict_FeeItem ON 

INSERT INTO Dict_FeeItem
(ID, FeeItemCode, SpellCode,  Unit) 
SELECT
	A.Id,   
	A.HISCheckCode AS FeeItemCode,  
	A.PYM AS SpellCode, 
	A.UnitName AS Unit 
FROM
	peis.dbo.FeeItem  A 
	
SET IDENTITY_INSERT dbo.Dict_FeeItem OFF




--
SELECT * FROM Dict_FeeItem  WHERE FeeItemCode='110500001A'
UPDATE Dict_FeeItem SET KeyNo=B.KEYNO
FROM Dict_FeeItem A 
LEFT JOIN  vi_HisFeeItem B ON A.FeeItemCode=B.FeeItemCode
WHERE  B. DeptCode in (
'3204',
'3203',
'3202',
'3201',
'3101',
'3001',
'2601',
'2101',
'1102',
'0501',
'0307')