
update document.document
	set 
		[sumItemValue] =abs(total.a),
		[sumSysItemValue]=abs(total.b)

		--select top 100  d.documentfullnr, [sumItemValue],total.a,[sumSysItemValue],total.b 
		from 
	 document.document d
	inner join
	(select sum(itemvalue) a,sum(SysItemValue) b,documentid from document.documentline
	where status =1 
	group by documentid) total on d.documentid = total.documentid
	where 	(abs([sumItemValue]) !=abs(total.a) or
		abs([sumSysItemValue]) !=abs(total.b) )
		and d.documentfullnr not like 'ko%'
