I have a question and I can’t come up with a good way to solve it, this is using SQLServer 2008R2.
I have 3 tables
Client, Invoice, Car
The client is duplicate n times, but each client has a ticket and one product.
So I am trying to consolidate the clients (with a unique identifier), now my question would be how to update the reference field on the product and ticket.
Example
**Client**
[Nombre]
,[Apellido_Paterno]
,[Apellido_Materno]
,[Sexo]
,[Estado_Civil]
,[Fecha_Nacimiento]
,[RFC]
,[Saludo]
,[Persona]
,[Razon_Social]
,[Direccion]
,[Colonia]
,[Municipio_Delegacion]
,[Estado]
,[Codigo_Postal]
,[Lada_Casa]
,[Telefono_Casa]
,[Ext_Telefono_Casa]
,[Lada_Oficina]
,[Telefono_Oficina]
,[Ext_Telefono_Oficina]
,[Telefono_Celular]
,[Email_Personal]
,[Vehiculo_Actual_Anterior]
,[Marca_Actual_Anterior]
,[AnioModelo_Actual_Anterior]
,[Color_Actual_Anterior]
,[Escolaridad]
,[Venta_Id]
,[Nombre1]
,[Nombre2]
**Invoice**
[Factura_Cliente]
,[Factura_Distribuidor]
,[Precio_Base_Vehiculo]
,[Precio_Accesorios]
,[Precio_Vehiculo_DeContado]
,[Descuento]
,[Incentivo_Calculado]
,[Fecha_Entrega_DelVehiculo]
,[Fecha_Factura_Cliente]
,[Clave_Distribuidor]
,[Seguro_Gratis]
,[Clave_Promocion]
,[Tipo_Venta]
,[Unidad_de_Intercambio]
,[Venta_Id]
**Car**
[Modelo]
,[Marca]
,[AnioModelo]
,[Basico]
,[Cabecera]
,[Version]
,[Color_Exterior]
,[Color_Interior]
,[VIN]
,[Motor]
,[Transmision]
,[Origen]
,[Basico_Linea_Modelo]
,[Venta_Id]
I can consolidate the clients, (even if they have discrepancies on their fields), but I can’t find a effective solution for this.
Edit: The first column on client shows the duplicate, while the second is the id that match the ticket and product.
i would make two more tables.
one for new consolidated clients (with all the same fields as the normal client)
and a mapping table between the old client and the new client.
this mapping table should store the id of the old one, and which i it was mapped to as a new one.
from here its pretty easy. update the other tables with the new id based on its current old id in the map table..