begin tran

declare @invoiceID uniqueidentifier = '7d90aecb-b26e-e611-80c5-9c8e994dc647'

	UPDATE document.invoice
	set accIssuerTaxCode = isnull(ifr.taxCode, '')
	from document.invoice
	left join firm.firm ifr on ifr.firmID = invoice.issuerID
	left join common.address ifa on ifa.remoteID = ifr.firmID and ifa.main = 1
	where invoiceID = @invoiceID

select * from document.invoice where invoiceid = @INVOICEid

rollback tran
