/*
W nawi�zani do rozmowy podaj� ci dane faktury, pod kt�r� chcia�am podmieni�
WZ:
Faktura M014/201411 (p�atnik i odbiorca powinien by� 8841 � QFG)
Jest aktualnie do niej przyporz�dkowane WZ nr WZ/468/2014,
korygowany (kontrahent 5370) a powinien WZ/480/2014 (kontrahent 8841).
*/

select * from firm.firm where firmnr = '8841' --E7A7AE2B-5A06-4747-82BC-C6C31036F32E
--M014/201411  4c44ea0a-0976-e411-940f-d89d6719e0c9
--WZ/468/2014  eef1c8c4-6775-e411-940e-d89d6719e0cb
--WZ/480/2014	f319e551-d576-e411-940f-d89d6719e0c9
--pozycja faktury c0409112-0976-e411-940f-d89d6719e0c9

select invoiceLineId, * from document.documentline where documentID
='f319e551-d576-e411-940f-d89d6719e0c9'

select * from document.documentLine where invoiceLineId = 'c0409112-0976-e411-940f-d89d6719e0c9'

--
update document.documentLine set  invoiceLineId =null where documentLineID = 'BE9C8DB5-6875-E411-940E-D89D6719E0CB'
update document.documentLine set  invoiceLineId ='c0409112-0976-e411-940f-d89d6719e0c9' where documentLineID = 'A439876D-D776-E411-940F-D89D6719E0C9'

update document.invoiceLine  set documentLineID = 'A439876D-D776-E411-940F-D89D6719E0C9' where  invoiceLineID='c0409112-0976-e411-940f-d89d6719e0c9'
