Begin TRANSACTION

	declare @documentid uniqueidentifier ='4a1af744-7678-e811-80d2-9c8e994dc647'
	declare @value decimal(18,2) =	'1394.73'

	update [document].[invoiceVatTable]
	set sysvatvalue =@value
	where invoiceid =@documentid

	update  [document].invoice
	set sysvatvalue = @value
	where invoiceid =@documentid

Rollback transsaction

Begin transaction

	declare @invoiceid uniqueidentifier ='4A1AF744-7678-E811-80D2-9C8E994DC647'

	/*suma z pozycji*/
	/*update [document].[invoiceVatTable] set
	sysvatvalue = t.total
	from [document].[invoiceVatTable] i inner join (
	select sum(sysvatvalue) total , invoiceid from  document.invoiceline  group by invoiceid) t
	on i.invoiceid=t.invoiceid
	 where i.[invoiceID]=@invoiceid
	 */

	--opcjonalnie recznie
	--update  [document].[invoiceVatTable]  set sysvatvalue =1394.73  where [invoiceID]=@invoiceid
	--update  [document].[invoice]  set sysvatvalue =1394.73  where [invoiceID]=@invoiceid

	select * from  [document].[invoiceVatTable]  where [invoiceID]=@invoiceid
	select * from  [document].[invoice]  where [invoiceID]=@invoiceid
rollback transaction
