Validate client ID to export in SQL Server

0

Friends, good evening, I hope I can explain myself well about the problem I'm having. I am currently doing an export in SQL With the following query:

SELECT        IDFactura, FechaDocumento, NombreCliente, NIT, DireccionFacturacion, FOLIO, Subfolio, Habitacion, SERIE, NumeroDoc, IDVendor, IDClienteIQware, DocType
FROM            POS_EDIFAC.dbo.V_InvoiceHeader
WHERE FechaDocumento = (SELECT CurrentHotelDate -1 FROM prProperty)

Obtaining a result like this:

Apart I have a table of clients with this structure:

What I am trying to do is to use the value NIT What is a unique customer identification code to make a comparison between this query and the customer table and in this way replace the value of the column IDClienteIQware with the information stored in the table of ClientesCXC in the column IDSAP , I leave an approximate result of what I need.

In summary, during my first consultation I need to compare the NIT with the NIT of the table of ClientesCXC and replace with the value with the column IDSAP and insert them in the column IDClienteIQware .

I hope to have explained myself well, it is a somewhat complicated issue but I know you will understand, thank you very much for your help.

    
asked by Gio Gómez 29.11.2018 в 04:59
source

0 answers